home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gcc_260.zip / gcc_260 / texinfo.tex (.txt) < prev    next >
LaTeX Document  |  1994-07-14  |  137KB  |  3,337 lines

  1. %% TeX macros to handle texinfo files
  2. %   Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 1994 Free Software Foundation, Inc.
  3. %This texinfo.tex file is free software; you can redistribute it and/or
  4. %modify it under the terms of the GNU General Public License as
  5. %published by the Free Software Foundation; either version 2, or (at
  6. %your option) any later version.
  7. %This texinfo.tex file is distributed in the hope that it will be
  8. %useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  9. %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  10. %General Public License for more details.
  11. %You should have received a copy of the GNU General Public License
  12. %along with this texinfo.tex file; see the file COPYING.  If not, write
  13. %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  14. %USA.
  15. %In other words, you are welcome to use, share and improve this program.
  16. %You are forbidden to forbid anyone else to use, share and improve
  17. %what you give them.   Help stamp out software-hoarding!
  18. % This automatically updates the version number based on RCS.
  19. \def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}}
  20. \deftexinfoversion$Revision: 2.131 $
  21. \message{Loading texinfo package [Version \texinfoversion]:}
  22. % Print the version number if in a .fmt file.
  23. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
  24. % Save some parts of plain tex whose names we will redefine.
  25. \let\ptextilde=\~
  26. \let\ptexlbrace=\{
  27. \let\ptexrbrace=\}
  28. \let\ptexdots=\dots
  29. \let\ptexdot=\.
  30. \let\ptexstar=\*
  31. \let\ptexend=\end
  32. \let\ptexbullet=\bullet
  33. \let\ptexb=\b
  34. \let\ptexc=\c
  35. \let\ptexi=\i
  36. \let\ptext=\t
  37. \let\ptexl=\l
  38. \let\ptexL=\L
  39. % Be sure we're in horizontal mode when doing a tie, since we make space
  40. % equivalent to this in @example-like environments. Otherwise, a space
  41. % at the beginning of a line will start with \penalty -- and
  42. % since \penalty is valid in vertical mode, we'd end up putting the
  43. % penalty on the vertical list instead of in the new paragraph.
  44. {\catcode`@ = 11
  45.  \gdef\tie{\leavevmode\penalty\@M\ }
  46. \let\~ = \tie                  % And make it available as @~.
  47. \message{Basics,}
  48. \chardef\other=12
  49. % If this character appears in an error message or help string, it
  50. % starts a new line in the output.
  51. \newlinechar = `^^J
  52. % Set up fixed words for English.
  53. \ifx\putwordChapter\undefined{\gdef\putwordChapter{Chapter}}\fi%
  54. \def\putwordInfo{Info}%
  55. \ifx\putwordSee\undefined{\gdef\putwordSee{See}}\fi%
  56. \ifx\putwordsee\undefined{\gdef\putwordsee{see}}\fi%
  57. \ifx\putwordfile\undefined{\gdef\putwordfile{file}}\fi%
  58. \ifx\putwordpage\undefined{\gdef\putwordpage{page}}\fi%
  59. \ifx\putwordsection\undefined{\gdef\putwordsection{section}}\fi%
  60. \ifx\putwordSection\undefined{\gdef\putwordSection{Section}}\fi%
  61. \ifx\putwordTableofContents\undefined{\gdef\putwordTableofContents{Table of Contents}}\fi%
  62. \ifx\putwordShortContents\undefined{\gdef\putwordShortContents{Short Contents}}\fi%
  63. \ifx\putwordAppendix\undefined{\gdef\putwordAppendix{Appendix}}\fi%
  64. % Ignore a token.
  65. \def\gobble#1{}
  66. \hyphenation{ap-pen-dix}
  67. \hyphenation{mini-buf-fer mini-buf-fers}
  68. \hyphenation{eshell}
  69. % Margin to add to right of even pages, to left of odd pages.
  70. \newdimen \bindingoffset  \bindingoffset=0pt
  71. \newdimen \normaloffset   \normaloffset=\hoffset
  72. \newdimen\pagewidth \newdimen\pageheight
  73. \pagewidth=\hsize \pageheight=\vsize
  74. % Sometimes it is convenient to have everything in the transcript file
  75. % and nothing on the terminal.  We don't just call \tracingall here,
  76. % since that produces some useless output on the terminal.
  77. \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  78. \def\loggingall{\tracingcommands2 \tracingstats2
  79.    \tracingpages1 \tracingoutput1 \tracinglostchars1
  80.    \tracingmacros2 \tracingparagraphs1 \tracingrestores1
  81.    \showboxbreadth\maxdimen\showboxdepth\maxdimen
  82. %---------------------Begin change-----------------------
  83. %%%% For @cropmarks command.
  84. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
  85. \newdimen\cornerlong \newdimen\cornerthick
  86. \newdimen \topandbottommargin
  87. \newdimen \outerhsize \newdimen \outervsize
  88. \cornerlong=1pc\cornerthick=.3pt    % These set size of cropmarks
  89. \outerhsize=7in
  90. %\outervsize=9.5in
  91. % Alternative @smallbook page size is 9.25in
  92. \outervsize=9.25in
  93. \topandbottommargin=.75in
  94. %---------------------End change-----------------------
  95. % \onepageout takes a vbox as an argument.  Note that \pagecontents
  96. % does insertions itself, but you have to call it yourself.
  97. \chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
  98. \def\onepageout#1{\hoffset=\normaloffset
  99. \ifodd\pageno  \advance\hoffset by \bindingoffset
  100. \else \advance\hoffset by -\bindingoffset\fi
  101. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  102. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
  103. {\let\hsize=\pagewidth \makefootline}}}%
  104. \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  105. %%%% For @cropmarks command %%%%
  106. % Here is a modification of the main output routine for Near East Publications
  107. % This provides right-angle cropmarks at all four corners.
  108. % The contents of the page are centerlined into the cropmarks,
  109. % and any desired binding offset is added as an \hskip on either
  110. % site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
  111. \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
  112. {\escapechar=`\\\relax % makes sure backslash is used in output files.
  113.          \shipout
  114.          \vbox to \outervsize{\hsize=\outerhsize
  115.                  \vbox{\line{\ewtop\hfill\ewtop}}
  116.                  \nointerlineskip
  117.                  \line{\vbox{\moveleft\cornerthick\nstop}
  118.                        \hfill
  119.                        \vbox{\moveright\cornerthick\nstop}}
  120.                  \vskip \topandbottommargin
  121.                  \centerline{\ifodd\pageno\hskip\bindingoffset\fi
  122.             \vbox{
  123.             {\let\hsize=\pagewidth \makeheadline}
  124.             \pagebody{#1}
  125.             {\let\hsize=\pagewidth \makefootline}}
  126.             \ifodd\pageno\else\hskip\bindingoffset\fi}
  127.          \vskip \topandbottommargin plus1fill minus1fill
  128.                  \boxmaxdepth\cornerthick
  129.                  \line{\vbox{\moveleft\cornerthick\nsbot}
  130.                        \hfill
  131.                        \vbox{\moveright\cornerthick\nsbot}}
  132.                  \nointerlineskip
  133.                  \vbox{\line{\ewbot\hfill\ewbot}}
  134.   \advancepageno
  135.   \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  136. % Do @cropmarks to get crop marks
  137. \def\cropmarks{\let\onepageout=\croppageout }
  138. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  139. {\catcode`\@ =11
  140. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  141. \dimen@=\dp#1 \unvbox#1
  142. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  143. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  144. % Here are the rules for the cropmarks.  Note that they are
  145. % offset so that the space between them is truly \outerhsize or \outervsize
  146. % (P. A. MacKay, 12 November, 1986)
  147. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  148. \def\nstop{\vbox
  149.   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  150. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  151. \def\nsbot{\vbox
  152.   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  153. % Parse an argument, then pass it to #1.  The argument is the rest of
  154. % the input line (except we remove a trailing comment).  #1 should be a
  155. % macro which expects an ordinary undelimited TeX argument.
  156. \def\parsearg#1{%
  157.   \let\next = #1%
  158.   \begingroup
  159.     \obeylines
  160.     \futurelet\temp\parseargx
  161. % If the next token is an obeyed space (from an @example environment or
  162. % the like), remove it and recurse.  Otherwise, we're done.
  163. \def\parseargx{%
  164.   % \obeyedspace is defined far below, after the definition of \sepspaces.
  165.   \ifx\obeyedspace\temp
  166.     \expandafter\parseargdiscardspace
  167.   \else
  168.     \expandafter\parseargline
  169.   \fi
  170. % Remove a single space (as the delimiter token to the macro call).
  171. {\obeyspaces %
  172.  \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
  173. {\obeylines %
  174.   \gdef\parseargline#1^^M{%
  175.     \endgroup % End of the group started in \parsearg.
  176.     %
  177.     % First remove any @c comment, then any @comment.
  178.     % Result of each macro is put in \toks0.
  179.     \argremovec #1\c\relax %
  180.     \expandafter\argremovecomment \the\toks0 \comment\relax %
  181.     %
  182.     % Call the caller's macro, saved as \next in \parsearg.
  183.     \expandafter\next\expandafter{\the\toks0}%
  184. % Since all \c{,omment} does is throw away the argument, we can let TeX
  185. % do that for us.  The \relax here is matched by the \relax in the call
  186. % in \parseargline; it could be more or less anything, its purpose is
  187. % just to delimit the argument to the \c.
  188. \def\argremovec#1\c#2\relax{\toks0 = {#1}}
  189. \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
  190. % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
  191. %    @end itemize  @c foo
  192. % will have two active spaces as part of the argument with the
  193. % `itemize'.  Here we remove all active spaces from #1, and assign the
  194. % result to \toks0.
  195. % This loses if there are any *other* active characters besides spaces
  196. % in the argument -- _ ^ +, for example -- since they get expanded.
  197. % Fortunately, Texinfo does not define any such commands.  (If it ever
  198. % does, the catcode of the characters in questionwill have to be changed
  199. % here.)  But this means we cannot call \removeactivespaces as part of
  200. % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
  201. % that \parsearg gets might well have any character at all in it.
  202. \def\removeactivespaces#1{%
  203.   \begingroup
  204.     \ignoreactivespaces
  205.     \edef\temp{#1}%
  206.     \global\toks0 = \expandafter{\temp}%
  207.   \endgroup
  208. % Change the active space to expand to nothing.
  209. \begingroup
  210.   \obeyspaces
  211.   \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
  212. \endgroup
  213. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  214. %% These are used to keep @begin/@end levels from running away
  215. %% Call \inENV within environments (after a \begingroup)
  216. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  217. \def\ENVcheck{%
  218. \ifENV\errmessage{Still within an environment.  Type Return to continue.}
  219. \endgroup\fi} % This is not perfect, but it should reduce lossage
  220. % @begin foo  is the same as @foo, for now.
  221. \newhelp\EMsimple{Type <Return> to continue.}
  222. \outer\def\begin{\parsearg\beginxxx}
  223. \def\beginxxx #1{%
  224. \expandafter\ifx\csname #1\endcsname\relax
  225. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  226. \csname #1\endcsname\fi}
  227. % @end foo executes the definition of \Efoo.
  228. \def\end{\parsearg\endxxx}
  229. \def\endxxx #1{%
  230.   \removeactivespaces{#1}%
  231.   \edef\endthing{\the\toks0}%
  232.   \expandafter\ifx\csname E\endthing\endcsname\relax
  233.     \expandafter\ifx\csname \endthing\endcsname\relax
  234.       % There's no \foo, i.e., no ``environment'' foo.
  235.       \errhelp = \EMsimple
  236.       \errmessage{Undefined command `@end \endthing'}%
  237.     \else
  238.       \unmatchedenderror\endthing
  239.     \fi
  240.   \else
  241.     % Everything's ok; the right environment has been started.
  242.     \csname E\endthing\endcsname
  243.   \fi
  244. % There is an environment #1, but it hasn't been started.  Give an error.
  245. \def\unmatchedenderror#1{%
  246.   \errhelp = \EMsimple
  247.   \errmessage{This `@end #1' doesn't have a matching `@#1'}%
  248. % Define the control sequence \E#1 to give an unmatched @end error.
  249. \def\defineunmatchedend#1{%
  250.   \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
  251. % Single-spacing is done by various environments (specifically, in
  252. % \nonfillstart and \quotations).
  253. \newskip\singlespaceskip \singlespaceskip = 12.5pt
  254. \def\singlespace{%
  255.   % Why was this kern here?  It messes up equalizing space above and below
  256.   % environments.  --karl, 6may93
  257.   %{\advance \baselineskip by -\singlespaceskip
  258.   %\kern \baselineskip}%
  259.   \setleading \singlespaceskip
  260. %% Simple single-character @ commands
  261. % @@ prints an @
  262. % Kludge this until the fonts are right (grr).
  263. \def\@{{\tt \char '100}}
  264. % This is turned off because it was never documented
  265. % and you can use @w{...} around a quote to suppress ligatures.
  266. %% Define @` and @' to be the same as ` and '
  267. %% but suppressing ligatures.
  268. %\def\`{{`}}
  269. %\def\'{{'}}
  270. % Used to generate quoted braces.
  271. \def\mylbrace {{\tt \char '173}}
  272. \def\myrbrace {{\tt \char '175}}
  273. \let\{=\mylbrace
  274. \let\}=\myrbrace
  275. % @: forces normal size whitespace following.
  276. \def\:{\spacefactor=1000 }
  277. % @* forces a line break.
  278. \def\*{\hfil\break\hbox{}\ignorespaces}
  279. % @. is an end-of-sentence period.
  280. \def\.{.\spacefactor=3000 }
  281. % @w prevents a word break.  Without the \leavevmode, @w at the
  282. % beginning of a paragraph, when TeX is still in vertical mode, would
  283. % produce a whole line of output instead of starting the paragraph.
  284. \def\w#1{\leavevmode\hbox{#1}}
  285. % @group ... @end group forces ... to be all on one page, by enclosing
  286. % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
  287. % to keep its height that of a normal line.  According to the rules for
  288. % \topskip (p.114 of the TeXbook), the glue inserted is
  289. % max (\topskip - \ht (first item), 0).  If that height is large,
  290. % therefore, no glue is inserted, and the space between the headline and
  291. % the text is small, which looks bad.
  292. \def\group{\begingroup
  293.   \ifnum\catcode13=\active \else
  294.     \errhelp = \groupinvalidhelp
  295.     \errmessage{@group invalid in context where filling is enabled}%
  296.   \fi
  297.   % The \vtop we start below produces a box with normal height and large
  298.   % depth; thus, TeX puts \baselineskip glue before it, and (when the
  299.   % next line of text is done) \lineskip glue after it.  (See p.82 of
  300.   % the TeXbook.)  Thus, space below is not quite equal to space
  301.   % above.  But it's pretty close.
  302.   \def\Egroup{%
  303.     \egroup           % End the \vtop.
  304.     \endgroup         % End the \group.
  305.   \vtop\bgroup
  306.     % We have to put a strut on the last line in case the @group is in
  307.     % the midst of an example, rather than completely enclosing it.
  308.     % Otherwise, the interline space between the last line of the group
  309.     % and the first line afterwards is too small.  But we can't put the
  310.     % strut in \Egroup, since there it would be on a line by itself.
  311.     % Hence this just inserts a strut at the beginning of each line.
  312.     \everypar = {\strut}%
  313.     %
  314.     % Since we have a strut on every line, we don't need any of TeX's
  315.     % normal interline spacing.
  316.     \offinterlineskip
  317.     %
  318.     % OK, but now we have to do something about blank
  319.     % lines in the input in @example-like environments, which normally
  320.     % just turn into \lisppar, which will insert no space now that we've
  321.     % turned off the interline space.  Simplest is to make them be an
  322.     % empty paragraph.
  323.     \ifx\par\lisppar
  324.       \edef\par{\leavevmode \par}%
  325.       %
  326.       % Reset ^^M's definition to new definition of \par.
  327.       \obeylines
  328.     \fi
  329.     %
  330.     % Do @comment since we are called inside an environment such as
  331.     % @example, where each end-of-line in the input causes an
  332.     % end-of-line in the output.  We don't want the end-of-line after
  333.     % the `@group' to put extra space in the output.  Since @group
  334.     % should appear on a line by itself (according to the Texinfo
  335.     % manual), we don't worry about eating any user text.
  336.     \comment
  337. % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  338. % message, so this ends up printing `@group can only ...'.
  339. \newhelp\groupinvalidhelp{%
  340. group can only be used in environments such as @example,^^J%
  341. where each line of input produces a line of output.}
  342. % @need space-in-mils
  343. % forces a page break if there is not space-in-mils remaining.
  344. \newdimen\mil  \mil=0.001in
  345. \def\need{\parsearg\needx}
  346. % Old definition--didn't work.
  347. %\def\needx #1{\par %
  348. %% This method tries to make TeX break the page naturally
  349. %% if the depth of the box does not fit.
  350. %{\baselineskip=0pt%
  351. %\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
  352. %\prevdepth=-1000pt
  353. \def\needx#1{%
  354.   % Go into vertical mode, so we don't make a big box in the middle of a
  355.   % paragraph.
  356.   \par
  357.   % Don't add any leading before our big empty box, but allow a page
  358.   % break, since the best break might be right here.
  359.   \allowbreak
  360.   \nointerlineskip
  361.   \vtop to #1\mil{\vfil}%
  362.   % TeX does not even consider page breaks if a penalty added to the
  363.   % main vertical list is 10000 or more.  But in order to see if the
  364.   % empty box we just added fits on the page, we must make it consider
  365.   % page breaks.  On the other hand, we don't want to actually break the
  366.   % page after the empty box.  So we use a penalty of 9999.
  367.   % There is an extremely small chance that TeX will actually break the
  368.   % page at this \penalty, if there are no other feasible breakpoints in
  369.   % sight.  (If the user is using lots of big @group commands, which
  370.   % almost-but-not-quite fill up a page, TeX will have a hard time doing
  371.   % good page breaking, for example.)  However, I could not construct an
  372.   % example where a page broke at this \penalty; if it happens in a real
  373.   % document, then we can reconsider our strategy.
  374.   \penalty9999
  375.   % Back up by the size of the box, whether we did a page break or not.
  376.   \kern -#1\mil
  377.   % Do not allow a page break right after this kern.
  378.   \nobreak
  379. % @br   forces paragraph break
  380. \let\br = \par
  381. % @dots{}  output some dots
  382. \def\dots{$\ldots$}
  383. % @page    forces the start of a new page
  384. \def\page{\par\vfill\supereject}
  385. % @exdent text....
  386. % outputs text on separate line in roman font, starting at standard page margin
  387. % This records the amount of indent in the innermost environment.
  388. % That's how much \exdent should take out.
  389. \newskip\exdentamount
  390. % This defn is used inside fill environments such as @defun.
  391. \def\exdent{\parsearg\exdentyyy}
  392. \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
  393. % This defn is used inside nofill environments such as @example.
  394. \def\nofillexdent{\parsearg\nofillexdentyyy}
  395. \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
  396. \leftline{\hskip\leftskip{\rm#1}}}}
  397. %\hbox{{\rm#1}}\hfil\break}}
  398. % @include file    insert text of that file as input.
  399. \def\include{\parsearg\includezzz}
  400. %Use \input\thisfile to avoid blank after \input, which may be an active
  401. %char (in which case the blank would become the \input argument).
  402. %The grouping keeps the value of \thisfile correct even when @include
  403. %is nested.
  404. \def\includezzz #1{\begingroup
  405. \def\thisfile{#1}\input\thisfile
  406. \endgroup}
  407. \def\thisfile{}
  408. % @center line   outputs that line, centered
  409. \def\center{\parsearg\centerzzz}
  410. \def\centerzzz #1{{\advance\hsize by -\leftskip
  411. \advance\hsize by -\rightskip
  412. \centerline{#1}}}
  413. % @sp n   outputs n lines of vertical space
  414. \def\sp{\parsearg\spxxx}
  415. \def\spxxx #1{\par \vskip #1\baselineskip}
  416. % @comment ...line which is ignored...
  417. % @c is the same as @comment
  418. % @ignore ... @end ignore  is another way to write a comment
  419. \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
  420. \parsearg \commentxxx}
  421. \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
  422. \let\c=\comment
  423. % Prevent errors for section commands.
  424. % Used in @ignore and in failing conditionals.
  425. \def\ignoresections{%
  426. \let\chapter=\relax
  427. \let\unnumbered=\relax
  428. \let\top=\relax
  429. \let\unnumberedsec=\relax
  430. \let\unnumberedsection=\relax
  431. \let\unnumberedsubsec=\relax
  432. \let\unnumberedsubsection=\relax
  433. \let\unnumberedsubsubsec=\relax
  434. \let\unnumberedsubsubsection=\relax
  435. \let\section=\relax
  436. \let\subsec=\relax
  437. \let\subsubsec=\relax
  438. \let\subsection=\relax
  439. \let\subsubsection=\relax
  440. \let\appendix=\relax
  441. \let\appendixsec=\relax
  442. \let\appendixsection=\relax
  443. \let\appendixsubsec=\relax
  444. \let\appendixsubsection=\relax
  445. \let\appendixsubsubsec=\relax
  446. \let\appendixsubsubsection=\relax
  447. \let\contents=\relax
  448. \let\smallbook=\relax
  449. \let\titlepage=\relax
  450. % Used in nested conditionals, where we have to parse the Texinfo source
  451. % and so want to turn off most commands, in case they are used
  452. % incorrectly.
  453. \def\ignoremorecommands{%
  454.   \let\defcv = \relax
  455.   \let\deffn = \relax
  456.   \let\deffnx = \relax
  457.   \let\defindex = \relax
  458.   \let\defivar = \relax
  459.   \let\defmac = \relax
  460.   \let\defmethod = \relax
  461.   \let\defop = \relax
  462.   \let\defopt = \relax
  463.   \let\defspec = \relax
  464.   \let\deftp = \relax
  465.   \let\deftypefn = \relax
  466.   \let\deftypefun = \relax
  467.   \let\deftypevar = \relax
  468.   \let\deftypevr = \relax
  469.   \let\defun = \relax
  470.   \let\defvar = \relax
  471.   \let\defvr = \relax
  472.   \let\ref = \relax
  473.   \let\xref = \relax
  474.   \let\printindex = \relax
  475.   \let\pxref = \relax
  476.   \let\settitle = \relax
  477.   \let\include = \relax
  478.   \let\lowersections = \relax
  479.   \let\down = \relax
  480.   \let\raisesections = \relax
  481.   \let\up = \relax
  482.   \let\set = \relax
  483.   \let\clear = \relax
  484.   \let\item = \relax
  485.   \let\message = \relax
  486. % Ignore @ignore ... @end ignore.
  487. \def\ignore{\doignore{ignore}}
  488. % Also ignore @ifinfo, @menu, and @direntry text.
  489. \def\ifinfo{\doignore{ifinfo}}
  490. \def\menu{\doignore{menu}}
  491. \def\direntry{\doignore{direntry}}
  492. % Ignore text until a line `@end #1'.
  493. \def\doignore#1{\begingroup
  494.   % Don't complain about control sequences we have declared \outer.
  495.   \ignoresections
  496.   % Define a command to swallow text until we reach `@end #1'.
  497.   \long\def\doignoretext##1\end #1{\enddoignore}%
  498.   % Make sure that spaces turn into tokens that match what \doignoretext wants.
  499.   \catcode32 = 10
  500.   % And now expand that command.
  501.   \doignoretext
  502. % What we do to finish off ignored text.
  503. \def\enddoignore{\endgroup\ignorespaces}%
  504. \newif\ifwarnedobs\warnedobsfalse
  505. \def\obstexwarn{%
  506.   \ifwarnedobs\relax\else
  507.   % We need to warn folks that they may have trouble with TeX 3.0.
  508.   % This uses \immediate\write16 rather than \message to get newlines.
  509.     \immediate\write16{}
  510.     \immediate\write16{***WARNING*** for users of Unix TeX 3.0!}
  511.     \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
  512.     \immediate\write16{If you are running another version of TeX, relax.}
  513.     \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
  514.     \immediate\write16{  Then upgrade your TeX installation if you can.}
  515.     \immediate\write16{If you are stuck with version 3.0, run the}
  516.     \immediate\write16{  script ``tex3patch'' from the Texinfo distribution}
  517.     \immediate\write16{  to use a workaround.}
  518.     \immediate\write16{}
  519.     \warnedobstrue
  520.     \fi
  521. % **In TeX 3.0, setting text in \nullfont hangs tex.  For a
  522. % workaround (which requires the file ``dummy.tfm'' to be installed),
  523. % uncomment the following line:
  524. %%%%%\font\nullfont=dummy\let\obstexwarn=\relax
  525. % Ignore text, except that we keep track of conditional commands for
  526. % purposes of nesting, up to an `@end #1' command.
  527. \def\nestedignore#1{%
  528.   \obstexwarn
  529.   % We must actually expand the ignored text to look for the @end
  530.   % command, so that nested ignore constructs work.  Thus, we put the
  531.   % text into a \vbox and then do nothing with the result.  To minimize
  532.   % the change of memory overflow, we follow the approach outlined on
  533.   % page 401 of the TeXbook: make the current font be a dummy font.
  534.   \setbox0 = \vbox\bgroup
  535.     % Don't complain about control sequences we have declared \outer.
  536.     \ignoresections
  537.     %
  538.     % Define `@end #1' to end the box, which will in turn undefine the
  539.     % @end command again.
  540.     \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
  541.     %
  542.     % We are going to be parsing Texinfo commands.  Most cause no
  543.     % trouble when they are used incorrectly, but some commands do
  544.     % complicated argument parsing or otherwise get confused, so we
  545.     % undefine them.
  546.     %
  547.     % We can't do anything about stray @-signs, unfortunately;
  548.     % they'll produce `undefined control sequence' errors.
  549.     \ignoremorecommands
  550.     %
  551.     % Set the current font to be \nullfont, a TeX primitive, and define
  552.     % all the font commands to also use \nullfont.  We don't use
  553.     % dummy.tfm, as suggested in the TeXbook, because not all sites
  554.     % might have that installed.  Therefore, math mode will still
  555.     % produce output, but that should be an extremely small amount of
  556.     % stuff compared to the main input.
  557.     %
  558.     \nullfont
  559.     \let\tenrm = \nullfont  \let\tenit = \nullfont  \let\tensl = \nullfont
  560.     \let\tenbf = \nullfont  \let\tentt = \nullfont  \let\smallcaps = \nullfont
  561.     \let\tensf = \nullfont
  562.     % Similarly for index fonts (mostly for their use in
  563.     % smallexample)
  564.     \let\indrm = \nullfont  \let\indit = \nullfont  \let\indsl = \nullfont
  565.     \let\indbf = \nullfont  \let\indtt = \nullfont  \let\indsc = \nullfont
  566.     \let\indsf = \nullfont
  567.     %
  568.     % Don't complain when characters are missing from the fonts.
  569.     \tracinglostchars = 0
  570.     %
  571.     % Don't bother to do space factor calculations.
  572.     \frenchspacing
  573.     %
  574.     % Don't report underfull hboxes.
  575.     \hbadness = 10000
  576.     %
  577.     % Do minimal line-breaking.
  578.     \pretolerance = 10000
  579.     %
  580.     % Do not execute instructions in @tex
  581.     \def\tex{\doignore{tex}}
  582. % @set VAR sets the variable VAR to an empty value.
  583. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
  584. % Since we want to separate VAR from REST-OF-LINE (which might be
  585. % empty), we can't just use \parsearg; we have to insert a space of our
  586. % own to delimit the rest of the line, and then take it out again if we
  587. % didn't need it.
  588. \def\set{\parsearg\setxxx}
  589. \def\setxxx#1{\setyyy#1 \endsetyyy}
  590. \def\setyyy#1 #2\endsetyyy{%
  591.   \def\temp{#2}%
  592.   \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
  593.   \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
  594.   \fi
  595. \def\setzzz#1#2 \endsetzzz{\expandafter\xdef\csname SET#1\endcsname{#2}}
  596. % @clear VAR clears (i.e., unsets) the variable VAR.
  597. \def\clear{\parsearg\clearxxx}
  598. \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
  599. % @value{foo} gets the text saved in variable foo.
  600. \def\value#1{\expandafter
  601.         \ifx\csname SET#1\endcsname\relax
  602.             {\{No value for ``#1''\}}
  603.         \else \csname SET#1\endcsname \fi}
  604. % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
  605. % with @set.
  606. \def\ifset{\parsearg\ifsetxxx}
  607. \def\ifsetxxx #1{%
  608.   \expandafter\ifx\csname SET#1\endcsname\relax
  609.     \expandafter\ifsetfail
  610.   \else
  611.     \expandafter\ifsetsucceed
  612.   \fi
  613. \def\ifsetsucceed{\conditionalsucceed{ifset}}
  614. \def\ifsetfail{\nestedignore{ifset}}
  615. \defineunmatchedend{ifset}
  616. % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
  617. % defined with @set, or has been undefined with @clear.
  618. \def\ifclear{\parsearg\ifclearxxx}
  619. \def\ifclearxxx #1{%
  620.   \expandafter\ifx\csname SET#1\endcsname\relax
  621.     \expandafter\ifclearsucceed
  622.   \else
  623.     \expandafter\ifclearfail
  624.   \fi
  625. \def\ifclearsucceed{\conditionalsucceed{ifclear}}
  626. \def\ifclearfail{\nestedignore{ifclear}}
  627. \defineunmatchedend{ifclear}
  628. % @iftex always succeeds; we read the text following, through @end
  629. % iftex).  But `@end iftex' should be valid only after an @iftex.
  630. \def\iftex{\conditionalsucceed{iftex}}
  631. \defineunmatchedend{iftex}
  632. % We can't just want to start a group at @iftex (for example) and end it
  633. % at @end iftex, since then @set commands inside the conditional have no
  634. % effect (they'd get reverted at the end of the group).  So we must
  635. % define \Eiftex to redefine itself to be its previous value.  (We can't
  636. % just define it to fail again with an ``unmatched end'' error, since
  637. % the @ifset might be nested.)
  638. \def\conditionalsucceed#1{%
  639.   \edef\temp{%
  640.     % Remember the current value of \E#1.
  641.     \let\nece{prevE#1} = \nece{E#1}%
  642.     %
  643.     % At the `@end #1', redefine \E#1 to be its previous value.
  644.     \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
  645.   \temp
  646. % We need to expand lots of \csname's, but we don't want to expand the
  647. % control sequences after we've constructed them.
  648. \def\nece#1{\expandafter\noexpand\csname#1\endcsname}
  649. % @asis just yields its argument.  Used with @table, for example.
  650. \def\asis#1{#1}
  651. % @math means output in math mode.
  652. % We don't use $'s directly in the definition of \math because control
  653. % sequences like \math are expanded when the toc file is written.  Then,
  654. % we read the toc file back, the $'s will be normal characters (as they
  655. % should be, according to the definition of Texinfo).  So we must use a
  656. % control sequence to switch into and out of math mode.
  657. % This isn't quite enough for @math to work properly in indices, but it
  658. % seems unlikely it will ever be needed there.
  659. \let\implicitmath = $
  660. \def\math#1{\implicitmath #1\implicitmath}
  661. % @bullet and @minus need the same treatment as @math, just above.
  662. \def\bullet{\implicitmath\ptexbullet\implicitmath}
  663. \def\minus{\implicitmath-\implicitmath}
  664. \def\node{\ENVcheck\parsearg\nodezzz}
  665. \def\nodezzz#1{\nodexxx [#1,]}
  666. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  667. \let\nwnode=\node
  668. \let\lastnode=\relax
  669. \def\donoderef{\ifx\lastnode\relax\else
  670. \expandafter\expandafter\expandafter\setref{\lastnode}\fi
  671. \global\let\lastnode=\relax}
  672. \def\unnumbnoderef{\ifx\lastnode\relax\else
  673. \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
  674. \global\let\lastnode=\relax}
  675. \def\appendixnoderef{\ifx\lastnode\relax\else
  676. \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
  677. \global\let\lastnode=\relax}
  678. \let\refill=\relax
  679. % @setfilename is done at the beginning of every texinfo file.
  680. % So open here the files we need to have open while reading the input.
  681. % This makes it possible to make a .fmt file for texinfo.
  682. \def\setfilename{%
  683.    \readauxfile
  684.    \opencontents
  685.    \openindices
  686.    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
  687.    \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  688.    \comment % Ignore the actual filename.
  689. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  690. \def\inforef #1{\inforefzzz #1,,,,**}
  691. \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
  692.   node \samp{\ignorespaces#1{}}}
  693. \message{fonts,}
  694. % Font-change commands.
  695. % Texinfo supports the sans serif font style, which plain TeX does not.
  696. % So we set up a \sf analogous to plain's \rm, etc.
  697. \newfam\sffam
  698. \def\sf{\fam=\sffam \tensf}
  699. \let\li = \sf % Sometimes we call it \li, not \sf.
  700. %% Try out Computer Modern fonts at \magstephalf
  701. \let\mainmagstep=\magstephalf
  702. \ifx\bigger\relax
  703. \let\mainmagstep=\magstep1
  704. \font\textrm=cmr12
  705. \font\texttt=cmtt12
  706. \else
  707. \font\textrm=cmr10 scaled \mainmagstep
  708. \font\texttt=cmtt10 scaled \mainmagstep
  709. % Instead of cmb10, you many want to use cmbx10.
  710. % cmbx10 is a prettier font on its own, but cmb10
  711. % looks better when embedded in a line with cmr10.
  712. \font\textbf=cmb10 scaled \mainmagstep
  713. \font\textit=cmti10 scaled \mainmagstep
  714. \font\textsl=cmsl10 scaled \mainmagstep
  715. \font\textsf=cmss10 scaled \mainmagstep
  716. \font\textsc=cmcsc10 scaled \mainmagstep
  717. \font\texti=cmmi10 scaled \mainmagstep
  718. \font\textsy=cmsy10 scaled \mainmagstep
  719. % A few fonts for @defun, etc.
  720. \font\defbf=cmbx10 scaled \magstep1 %was 1314
  721. \font\deftt=cmtt10 scaled \magstep1
  722. \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
  723. % Fonts for indices and small examples.
  724. % We actually use the slanted font rather than the italic,
  725. % because texinfo normally uses the slanted fonts for that.
  726. % Do not make many font distinctions in general in the index, since they
  727. % aren't very useful.
  728. \font\ninett=cmtt9
  729. \font\indrm=cmr9
  730. \font\indit=cmsl9
  731. \let\indsl=\indit
  732. \let\indtt=\ninett
  733. \let\indsf=\indrm
  734. \let\indbf=\indrm
  735. \let\indsc=\indrm
  736. \font\indi=cmmi9
  737. \font\indsy=cmsy9
  738. % Fonts for headings
  739. \font\chaprm=cmbx12 scaled \magstep2
  740. \font\chapit=cmti12 scaled \magstep2
  741. \font\chapsl=cmsl12 scaled \magstep2
  742. \font\chaptt=cmtt12 scaled \magstep2
  743. \font\chapsf=cmss12 scaled \magstep2
  744. \let\chapbf=\chaprm
  745. \font\chapsc=cmcsc10 scaled\magstep3
  746. \font\chapi=cmmi12 scaled \magstep2
  747. \font\chapsy=cmsy10 scaled \magstep3
  748. \font\secrm=cmbx12 scaled \magstep1
  749. \font\secit=cmti12 scaled \magstep1
  750. \font\secsl=cmsl12 scaled \magstep1
  751. \font\sectt=cmtt12 scaled \magstep1
  752. \font\secsf=cmss12 scaled \magstep1
  753. \font\secbf=cmbx12 scaled \magstep1
  754. \font\secsc=cmcsc10 scaled\magstep2
  755. \font\seci=cmmi12 scaled \magstep1
  756. \font\secsy=cmsy10 scaled \magstep2
  757. % \font\ssecrm=cmbx10 scaled \magstep1    % This size an font looked bad.
  758. % \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
  759. % \font\ssecsl=cmsl10 scaled \magstep1
  760. % \font\ssectt=cmtt10 scaled \magstep1
  761. % \font\ssecsf=cmss10 scaled \magstep1
  762. %\font\ssecrm=cmb10 scaled 1315    % Note the use of cmb rather than cmbx.
  763. %\font\ssecit=cmti10 scaled 1315    % Also, the size is a little larger than
  764. %\font\ssecsl=cmsl10 scaled 1315    % being scaled magstep1.
  765. %\font\ssectt=cmtt10 scaled 1315
  766. %\font\ssecsf=cmss10 scaled 1315
  767. %\let\ssecbf=\ssecrm
  768. \font\ssecrm=cmbx12 scaled \magstephalf
  769. \font\ssecit=cmti12 scaled \magstephalf
  770. \font\ssecsl=cmsl12 scaled \magstephalf
  771. \font\ssectt=cmtt12 scaled \magstephalf
  772. \font\ssecsf=cmss12 scaled \magstephalf
  773. \font\ssecbf=cmbx12 scaled \magstephalf
  774. \font\ssecsc=cmcsc10 scaled \magstep1
  775. \font\sseci=cmmi12 scaled \magstephalf
  776. \font\ssecsy=cmsy10 scaled \magstep1
  777. % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
  778. % but that is not a standard magnification.
  779. % Fonts for title page:
  780. \font\titlerm = cmbx12 scaled \magstep3
  781. \let\authorrm = \secrm
  782. % In order for the font changes to affect most math symbols and letters,
  783. % we have to define the \textfont of the standard families.  Since
  784. % texinfo doesn't allow for producing subscripts and superscripts, we
  785. % don't bother to reset \scriptfont and \scriptscriptfont (which would
  786. % also require loading a lot more fonts).
  787. \def\resetmathfonts{%
  788.   \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
  789.   \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
  790.   \textfont\ttfam = \tentt \textfont\sffam = \tensf
  791. % The font-changing commands redefine the meanings of \tenSTYLE, instead
  792. % of just \STYLE.  We do this so that font changes will continue to work
  793. % in math mode, where it is the current \fam that is relevant in most
  794. % cases, not the current.  Plain TeX does, for example,
  795. % \def\bf{\fam=\bffam \tenbf}  By redefining \tenbf, we obviate the need
  796. % to redefine \bf itself.
  797. \def\textfonts{%
  798.   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
  799.   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
  800.   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
  801.   \resetmathfonts}
  802. \def\chapfonts{%
  803.   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
  804.   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
  805.   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
  806.   \resetmathfonts}
  807. \def\secfonts{%
  808.   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
  809.   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
  810.   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
  811.   \resetmathfonts}
  812. \def\subsecfonts{%
  813.   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
  814.   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
  815.   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
  816.   \resetmathfonts}
  817. \def\indexfonts{%
  818.   \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
  819.   \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
  820.   \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy
  821.   \resetmathfonts}
  822. % Set up the default fonts, so we can use them for creating boxes.
  823. \textfonts
  824. % Count depth in font-changes, for error checks
  825. \newcount\fontdepth \fontdepth=0
  826. % Fonts for short table of contents.
  827. \font\shortcontrm=cmr12
  828. \font\shortcontbf=cmbx12
  829. \font\shortcontsl=cmsl12
  830. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  831. %% serif) and @ii for TeX italic
  832. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  833. % unless the following character is such as not to need one.
  834. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  835. \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
  836. \let\i=\smartitalic
  837. \let\var=\smartitalic
  838. \let\dfn=\smartitalic
  839. \let\emph=\smartitalic
  840. \let\cite=\smartitalic
  841. \def\b#1{{\bf #1}}
  842. \let\strong=\b
  843. % We can't just use \exhyphenpenalty, because that only has effect at
  844. % the end of a paragraph.  Restore normal hyphenation at the end of the
  845. % group within which \nohyphenation is presumably called.
  846. \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
  847. \def\restorehyphenation{\hyphenchar\font = `- }
  848. \def\t#1{%
  849.   {\tt \nohyphenation \rawbackslash \frenchspacing #1}%
  850.   \null
  851. \let\ttfont = \t
  852. %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
  853. \def\samp #1{`\tclose{#1}'\null}
  854. \def\key #1{{\tt \nohyphenation \uppercase{#1}}\null}
  855. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  856. \let\file=\samp
  857. % @code is a modification of @t,
  858. % which makes spaces the same size as normal in the surrounding text.
  859. \def\tclose#1{%
  860.     % Change normal interword space to be same as for the current font.
  861.     \spaceskip = \fontdimen2\font
  862.     %
  863.     % Switch to typewriter.
  864.     \tt
  865.     %
  866.     % But `\ ' produces the large typewriter interword space.
  867.     \def\ {{\spaceskip = 0pt{} }}%
  868.     %
  869.     % Turn off hyphenation.
  870.     \nohyphenation
  871.     %
  872.     \rawbackslash
  873.     \frenchspacing
  874.     #1%
  875.   \null
  876. % We *must* turn on hyphenation at `-' and `_' in \code.
  877. % Otherwise, it is too hard to avoid overful hboxes
  878. % in the Emacs manual, the Library manual, etc.
  879. % Unfortunately, TeX uses one parameter (\hyphenchar) to control
  880. % both hyphenation at - and hyphenation within words.
  881. % We must therefore turn them both off (\tclose does that)
  882. % and arrange explicitly to hyphenate an a dash.
  883. %  -- rms.
  884. \catcode`\-=\active
  885. \catcode`\_=\active
  886. \global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex}
  887. % The following is used by \doprintindex to insure that long function names
  888. % wrap around.  It is necessary for - and _ to be active before the index is
  889. % read from the file, as \entry parses the arguments long before \code is
  890. % ever called.  -- mycroft
  891. \global\def\indexbreaks{\catcode`\-=\active \let-\realdash \catcode`\_=\active \let_\realunder}
  892. \def\realdash{-}
  893. \def\realunder{_}
  894. \def\codedash{-\discretionary{}{}{}}
  895. \def\codeunder{\normalunderscore\discretionary{}{}{}}
  896. \def\codex #1{\tclose{#1}\endgroup}
  897. %\let\exp=\tclose  %Was temporary
  898. % @kbd is like @code, except that if the argument is just one @key command,
  899. % then @kbd has no effect.
  900. \def\xkey{\key}
  901. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  902. \ifx\one\xkey\ifx\threex\three \key{#2}%
  903. \else\tclose{\look}\fi
  904. \else\tclose{\look}\fi}
  905. % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
  906. % argument is to make the input look right: @dmn{pt} instead of
  907. % @dmn{}pt.
  908. \def\dmn#1{\thinspace #1}
  909. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  910. \def\l#1{{\li #1}\null}        %
  911. \def\r#1{{\rm #1}}        % roman font
  912. % Use of \lowercase was suggested.
  913. \def\sc#1{{\smallcaps#1}}    % smallcaps font
  914. \def\ii#1{{\it #1}}        % italic font
  915. \message{page headings,}
  916. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  917. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  918. % First the title page.  Must do @settitle before @titlepage.
  919. \def\titlefont#1{{\titlerm #1}}
  920. \newif\ifseenauthor
  921. \newif\iffinishedtitlepage
  922. \def\shorttitlepage{\parsearg\shorttitlepagezzz}
  923. \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
  924.     \endgroup\page\hbox{}\page}
  925. \def\titlepage{\begingroup \parindent=0pt \textfonts
  926.    \let\subtitlerm=\tenrm
  927. % I deinstalled the following change because \cmr12 is undefined.
  928. % This change was not in the ChangeLog anyway.  --rms.
  929. %   \let\subtitlerm=\cmr12
  930.    \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  931.    \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  932.    % Leave some space at the very top of the page.
  933.    \vglue\titlepagetopglue
  934.    % Now you can print the title using @title.
  935.    \def\title{\parsearg\titlezzz}%
  936.    \def\titlezzz##1{\leftline{\titlefont{##1}}
  937.             % print a rule at the page bottom also.
  938.             \finishedtitlepagefalse
  939.             \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
  940.    % No rule at page bottom unless we print one at the top with @title.
  941.    \finishedtitlepagetrue
  942.    % Now you can put text using @subtitle.
  943.    \def\subtitle{\parsearg\subtitlezzz}%
  944.    \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  945.    % @author should come last, but may come many times.
  946.    \def\author{\parsearg\authorzzz}%
  947.    \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  948.       {\authorfont \leftline{##1}}}%
  949.    % Most title ``pages'' are actually two pages long, with space
  950.    % at the top of the second.  We don't want the ragged left on the second.
  951.    \let\oldpage = \page
  952.    \def\page{%
  953.       \iffinishedtitlepage\else
  954.      \finishtitlepage
  955.       \fi
  956.       \oldpage
  957.       \let\page = \oldpage
  958.       \hbox{}}%
  959. %   \def\page{\oldpage \hbox{}}
  960. \def\Etitlepage{%
  961.    \iffinishedtitlepage\else
  962.       \finishtitlepage
  963.    \fi
  964.    % It is important to do the page break before ending the group,
  965.    % because the headline and footline are only empty inside the group.
  966.    % If we use the new definition of \page, we always get a blank page
  967.    % after the title page, which we certainly don't want.
  968.    \oldpage
  969.    \endgroup
  970.    \HEADINGSon
  971. \def\finishtitlepage{%
  972.    \vskip4pt \hrule height 2pt width \hsize
  973.    \vskip\titlepagebottomglue
  974.    \finishedtitlepagetrue
  975. %%% Set up page headings and footings.
  976. \let\thispage=\folio
  977. \newtoks \evenheadline    % Token sequence for heading line of even pages
  978. \newtoks \oddheadline     % Token sequence for heading line of odd pages
  979. \newtoks \evenfootline    % Token sequence for footing line of even pages
  980. \newtoks \oddfootline     % Token sequence for footing line of odd pages
  981. % Now make Tex use those variables
  982. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
  983.                             \else \the\evenheadline \fi}}
  984. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
  985.                             \else \the\evenfootline \fi}\HEADINGShook}
  986. \let\HEADINGShook=\relax
  987. % Commands to set those variables.
  988. % For example, this is what  @headings on  does
  989. % @evenheading @thistitle|@thispage|@thischapter
  990. % @oddheading @thischapter|@thispage|@thistitle
  991. % @evenfooting @thisfile||
  992. % @oddfooting ||@thisfile
  993. \def\evenheading{\parsearg\evenheadingxxx}
  994. \def\oddheading{\parsearg\oddheadingxxx}
  995. \def\everyheading{\parsearg\everyheadingxxx}
  996. \def\evenfooting{\parsearg\evenfootingxxx}
  997. \def\oddfooting{\parsearg\oddfootingxxx}
  998. \def\everyfooting{\parsearg\everyfootingxxx}
  999. {\catcode`\@=0 %
  1000. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  1001. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  1002. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1003. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  1004. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  1005. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1006. \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
  1007. \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
  1008. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  1009. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1010. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  1011. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  1012. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1013. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  1014. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  1015. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1016. \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
  1017. \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
  1018. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
  1019. \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1020. }% unbind the catcode of @.
  1021. % @headings double    turns headings on for double-sided printing.
  1022. % @headings single    turns headings on for single-sided printing.
  1023. % @headings off        turns them off.
  1024. % @headings on        same as @headings double, retained for compatibility.
  1025. % @headings after    turns on double-sided headings after this page.
  1026. % @headings doubleafter    turns on double-sided headings after this page.
  1027. % @headings singleafter turns on single-sided headings after this page.
  1028. % By default, they are off.
  1029. \def\headings #1 {\csname HEADINGS#1\endcsname}
  1030. \def\HEADINGSoff{
  1031. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  1032. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  1033. \HEADINGSoff
  1034. % When we turn headings on, set the page number to 1.
  1035. % For double-sided printing, put current file name in lower left corner,
  1036. % chapter name on inside top of right hand pages, document
  1037. % title on inside top of left hand pages, and page numbers on outside top
  1038. % edge of all pages.
  1039. \def\HEADINGSdouble{
  1040. %\pagealignmacro
  1041. \global\pageno=1
  1042. \global\evenfootline={\hfil}
  1043. \global\oddfootline={\hfil}
  1044. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1045. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1046. % For single-sided printing, chapter title goes across top left of page,
  1047. % page number on top right.
  1048. \def\HEADINGSsingle{
  1049. %\pagealignmacro
  1050. \global\pageno=1
  1051. \global\evenfootline={\hfil}
  1052. \global\oddfootline={\hfil}
  1053. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1054. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1055. \def\HEADINGSon{\HEADINGSdouble}
  1056. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  1057. \let\HEADINGSdoubleafter=\HEADINGSafter
  1058. \def\HEADINGSdoublex{%
  1059. \global\evenfootline={\hfil}
  1060. \global\oddfootline={\hfil}
  1061. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1062. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1063. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  1064. \def\HEADINGSsinglex{%
  1065. \global\evenfootline={\hfil}
  1066. \global\oddfootline={\hfil}
  1067. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1068. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1069. % Subroutines used in generating headings
  1070. % Produces Day Month Year style of output.
  1071. \def\today{\number\day\space
  1072. \ifcase\month\or
  1073. January\or February\or March\or April\or May\or June\or
  1074. July\or August\or September\or October\or November\or December\fi
  1075. \space\number\year}
  1076. % Use this if you want the Month Day, Year style of output.
  1077. %\def\today{\ifcase\month\or
  1078. %January\or February\or March\or April\or May\or June\or
  1079. %July\or August\or September\or October\or November\or December\fi
  1080. %\space\number\day, \number\year}
  1081. % @settitle line...  specifies the title of the document, for headings
  1082. % It generates no output of its own
  1083. \def\thistitle{No Title}
  1084. \def\settitle{\parsearg\settitlezzz}
  1085. \def\settitlezzz #1{\gdef\thistitle{#1}}
  1086. \message{tables,}
  1087. % @tabs -- simple alignment
  1088. % These don't work.  For one thing, \+ is defined as outer.
  1089. % So these macros cannot even be defined.
  1090. %\def\tabs{\parsearg\tabszzz}
  1091. %\def\tabszzz #1{\settabs\+#1\cr}
  1092. %\def\tabline{\parsearg\tablinezzz}
  1093. %\def\tablinezzz #1{\+#1\cr}
  1094. %\def\&{&}
  1095. % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
  1096. % default indentation of table text
  1097. \newdimen\tableindent \tableindent=.8in
  1098. % default indentation of @itemize and @enumerate text
  1099. \newdimen\itemindent  \itemindent=.3in
  1100. % margin between end of table item and start of table text.
  1101. \newdimen\itemmargin  \itemmargin=.1in
  1102. % used internally for \itemindent minus \itemmargin
  1103. \newdimen\itemmax
  1104. % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
  1105. % these defs.
  1106. % They also define \itemindex
  1107. % to index the item name in whatever manner is desired (perhaps none).
  1108. \newif\ifitemxneedsnegativevskip
  1109. \def\itemxpar{\par\ifitemxneedsnegativevskip\vskip-\parskip\nobreak\fi}
  1110. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  1111. \def\internalBitemx{\itemxpar \parsearg\itemzzz}
  1112. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  1113. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
  1114. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  1115. \def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
  1116. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
  1117.                  \itemzzz {#1}}
  1118. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
  1119.                  \itemzzz {#1}}
  1120. \def\itemzzz #1{\begingroup %
  1121.   \advance\hsize by -\rightskip
  1122.   \advance\hsize by -\tableindent
  1123.   \setbox0=\hbox{\itemfont{#1}}%
  1124.   \itemindex{#1}%
  1125.   \nobreak % This prevents a break before @itemx.
  1126.   % Be sure we are not still in the middle of a paragraph.
  1127.   %{\parskip = 0in
  1128.   %\par
  1129.   %}%
  1130.   % If the item text does not fit in the space we have, put it on a line
  1131.   % by itself, and do not allow a page break either before or after that
  1132.   % line.  We do not start a paragraph here because then if the next
  1133.   % command is, e.g., @kindex, the whatsit would get put into the
  1134.   % horizontal list on a line by itself, resulting in extra blank space.
  1135.   \ifdim \wd0>\itemmax
  1136.     %
  1137.     % Make this a paragraph so we get the \parskip glue and wrapping,
  1138.     % but leave it ragged-right.
  1139.     \begingroup
  1140.       \advance\leftskip by-\tableindent
  1141.       \advance\hsize by\tableindent
  1142.       \advance\rightskip by0pt plus1fil
  1143.       \leavevmode\unhbox0\par
  1144.     \endgroup
  1145.     %
  1146.     % We're going to be starting a paragraph, but we don't want the
  1147.     % \parskip glue -- logically it's part of the @item we just started.
  1148.     \nobreak \vskip-\parskip
  1149.     %
  1150.     % Stop a page break at the \parskip glue coming up.  Unfortunately
  1151.     % we can't prevent a possible page break at the following
  1152.     % \baselineskip glue.
  1153.     \nobreak
  1154.     \endgroup
  1155.     \itemxneedsnegativevskipfalse
  1156.   \else
  1157.     % The item text fits into the space.  Start a paragraph, so that the
  1158.     % following text (if any) will end up on the same line.  Since that
  1159.     % text will be indented by \tableindent, we make the item text be in
  1160.     % a zero-width box.
  1161.     \noindent
  1162.     \rlap{\hskip -\tableindent\box0}\ignorespaces%
  1163.     \endgroup%
  1164.     \itemxneedsnegativevskiptrue%
  1165.   \fi
  1166. \def\item{\errmessage{@item while not in a table}}
  1167. \def\itemx{\errmessage{@itemx while not in a table}}
  1168. \def\kitem{\errmessage{@kitem while not in a table}}
  1169. \def\kitemx{\errmessage{@kitemx while not in a table}}
  1170. \def\xitem{\errmessage{@xitem while not in a table}}
  1171. \def\xitemx{\errmessage{@xitemx while not in a table}}
  1172. %% Contains a kludge to get @end[description] to work
  1173. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  1174. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  1175. {\obeylines\obeyspaces%
  1176. \gdef\tablex #1^^M{%
  1177. \tabley\dontindex#1        \endtabley}}
  1178. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  1179. {\obeylines\obeyspaces%
  1180. \gdef\ftablex #1^^M{%
  1181. \tabley\fnitemindex#1        \endtabley
  1182. \def\Eftable{\endgraf\afterenvbreak\endgroup}%
  1183. \let\Etable=\relax}}
  1184. \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
  1185. {\obeylines\obeyspaces%
  1186. \gdef\vtablex #1^^M{%
  1187. \tabley\vritemindex#1        \endtabley
  1188. \def\Evtable{\endgraf\afterenvbreak\endgroup}%
  1189. \let\Etable=\relax}}
  1190. \def\dontindex #1{}
  1191. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  1192. \def\vritemindex #1{\doind {vr}{\code{#1}}}%
  1193. {\obeyspaces %
  1194. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  1195. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  1196. \def\tablez #1#2#3#4#5#6{%
  1197. \aboveenvbreak %
  1198. \begingroup %
  1199. \def\Edescription{\Etable}% Neccessary kludge.
  1200. \let\itemindex=#1%
  1201. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  1202. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  1203. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  1204. \def\itemfont{#2}%
  1205. \itemmax=\tableindent %
  1206. \advance \itemmax by -\itemmargin %
  1207. \advance \leftskip by \tableindent %
  1208. \exdentamount=\tableindent
  1209. \parindent = 0pt
  1210. \parskip = \smallskipamount
  1211. \ifdim \parskip=0pt \parskip=2pt \fi%
  1212. \def\Etable{\endgraf\afterenvbreak\endgroup}%
  1213. \let\item = \internalBitem %
  1214. \let\itemx = \internalBitemx %
  1215. \let\kitem = \internalBkitem %
  1216. \let\kitemx = \internalBkitemx %
  1217. \let\xitem = \internalBxitem %
  1218. \let\xitemx = \internalBxitemx %
  1219. % This is the counter used by @enumerate, which is really @itemize
  1220. \newcount \itemno
  1221. \def\itemize{\parsearg\itemizezzz}
  1222. \def\itemizezzz #1{%
  1223.   \begingroup % ended by the @end itemsize
  1224.   \itemizey {#1}{\Eitemize}
  1225. \def\itemizey #1#2{%
  1226. \aboveenvbreak %
  1227. \itemmax=\itemindent %
  1228. \advance \itemmax by -\itemmargin %
  1229. \advance \leftskip by \itemindent %
  1230. \exdentamount=\itemindent
  1231. \parindent = 0pt %
  1232. \parskip = \smallskipamount %
  1233. \ifdim \parskip=0pt \parskip=2pt \fi%
  1234. \def#2{\endgraf\afterenvbreak\endgroup}%
  1235. \def\itemcontents{#1}%
  1236. \let\item=\itemizeitem}
  1237. % Set sfcode to normal for the chars that usually have another value.
  1238. % These are `.?!:;,'
  1239. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  1240.   \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  1241. % \splitoff TOKENS\endmark defines \first to be the first token in
  1242. % TOKENS, and \rest to be the remainder.
  1243. \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
  1244. % Allow an optional argument of an uppercase letter, lowercase letter,
  1245. % or number, to specify the first label in the enumerated list.  No
  1246. % argument is the same as `1'.
  1247. \def\enumerate{\parsearg\enumeratezzz}
  1248. \def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
  1249. \def\enumeratey #1 #2\endenumeratey{%
  1250.   \begingroup % ended by the @end enumerate
  1251.   % If we were given no argument, pretend we were given `1'.
  1252.   \def\thearg{#1}%
  1253.   \ifx\thearg\empty \def\thearg{1}\fi
  1254.   % Detect if the argument is a single token.  If so, it might be a
  1255.   % letter.  Otherwise, the only valid thing it can be is a number.
  1256.   % (We will always have one token, because of the test we just made.
  1257.   % This is a good thing, since \splitoff doesn't work given nothing at
  1258.   % all -- the first parameter is undelimited.)
  1259.   \expandafter\splitoff\thearg\endmark
  1260.   \ifx\rest\empty
  1261.     % Only one token in the argument.  It could still be anything.
  1262.     % A ``lowercase letter'' is one whose \lccode is nonzero.
  1263.     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
  1264.     %   not equal to itself.
  1265.     % Otherwise, we assume it's a number.
  1266.     %
  1267.     % We need the \relax at the end of the \ifnum lines to stop TeX from
  1268.     % continuing to look for a <number>.
  1269.     %
  1270.     \ifnum\lccode\expandafter`\thearg=0\relax
  1271.       \numericenumerate % a number (we hope)
  1272.     \else
  1273.       % It's a letter.
  1274.       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
  1275.         \lowercaseenumerate % lowercase letter
  1276.       \else
  1277.         \uppercaseenumerate % uppercase letter
  1278.       \fi
  1279.     \fi
  1280.   \else
  1281.     % Multiple tokens in the argument.  We hope it's a number.
  1282.     \numericenumerate
  1283.   \fi
  1284. % An @enumerate whose labels are integers.  The starting integer is
  1285. % given in \thearg.
  1286. \def\numericenumerate{%
  1287.   \itemno = \thearg
  1288.   \startenumeration{\the\itemno}%
  1289. % The starting (lowercase) letter is in \thearg.
  1290. \def\lowercaseenumerate{%
  1291.   \itemno = \expandafter`\thearg
  1292.   \startenumeration{%
  1293.     % Be sure we're not beyond the end of the alphabet.
  1294.     \ifnum\itemno=0
  1295.       \errmessage{No more lowercase letters in @enumerate; get a bigger
  1296.                   alphabet}%
  1297.     \fi
  1298.     \char\lccode\itemno
  1299. % The starting (uppercase) letter is in \thearg.
  1300. \def\uppercaseenumerate{%
  1301.   \itemno = \expandafter`\thearg
  1302.   \startenumeration{%
  1303.     % Be sure we're not beyond the end of the alphabet.
  1304.     \ifnum\itemno=0
  1305.       \errmessage{No more uppercase letters in @enumerate; get a bigger
  1306.                   alphabet}
  1307.     \fi
  1308.     \char\uccode\itemno
  1309. % Call itemizey, adding a period to the first argument and supplying the
  1310. % common last two arguments.  Also subtract one from the initial value in
  1311. % \itemno, since @item increments \itemno.
  1312. \def\startenumeration#1{%
  1313.   \advance\itemno by -1
  1314.   \itemizey{#1.}\Eenumerate\flushcr
  1315. % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
  1316. % to @enumerate.
  1317. \def\alphaenumerate{\enumerate{a}}
  1318. \def\capsenumerate{\enumerate{A}}
  1319. \def\Ealphaenumerate{\Eenumerate}
  1320. \def\Ecapsenumerate{\Eenumerate}
  1321. % Definition of @item while inside @itemize.
  1322. \def\itemizeitem{%
  1323. \advance\itemno by 1
  1324. {\let\par=\endgraf \smallbreak}%
  1325. \ifhmode \errmessage{\in hmode at itemizeitem}\fi
  1326. {\parskip=0in \hskip 0pt
  1327. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  1328. \vadjust{\penalty 1200}}%
  1329. \flushcr}
  1330. \message{indexing,}
  1331. % Index generation facilities
  1332. % Define \newwrite to be identical to plain tex's \newwrite
  1333. % except not \outer, so it can be used within \newindex.
  1334. {\catcode`\@=11
  1335. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  1336. % \newindex {foo} defines an index named foo.
  1337. % It automatically defines \fooindex such that
  1338. % \fooindex ...rest of line... puts an entry in the index foo.
  1339. % It also defines \fooindfile to be the number of the output channel for
  1340. % the file that    accumulates this index.  The file's extension is foo.
  1341. % The name of an index should be no more than 2 characters long
  1342. % for the sake of vms.
  1343. \def\newindex #1{
  1344. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1345. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1346. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1347. \noexpand\doindex {#1}}
  1348. % @defindex foo  ==  \newindex{foo}
  1349. \def\defindex{\parsearg\newindex}
  1350. % Define @defcodeindex, like @defindex except put all entries in @code.
  1351. \def\newcodeindex #1{
  1352. \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
  1353. \openout \csname#1indfile\endcsname \jobname.#1    % Open the file
  1354. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1355. \noexpand\docodeindex {#1}}
  1356. \def\defcodeindex{\parsearg\newcodeindex}
  1357. % @synindex foo bar    makes index foo feed into index bar.
  1358. % Do this instead of @defindex foo if you don't want it as a separate index.
  1359. \def\synindex #1 #2 {%
  1360. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1361. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1362. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1363. \noexpand\doindex {#2}}%
  1364. % @syncodeindex foo bar   similar, but put all entries made for index foo
  1365. % inside @code.
  1366. \def\syncodeindex #1 #2 {%
  1367. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  1368. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  1369. \expandafter\xdef\csname#1index\endcsname{%    % Define \xxxindex
  1370. \noexpand\docodeindex {#2}}%
  1371. % Define \doindex, the driver for all \fooindex macros.
  1372. % Argument #1 is generated by the calling \fooindex macro,
  1373. %  and it is "foo", the name of the index.
  1374. % \doindex just uses \parsearg; it calls \doind for the actual work.
  1375. % This is because \doind is more useful to call from other macros.
  1376. % There is also \dosubind {index}{topic}{subtopic}
  1377. % which makes an entry in a two-level index such as the operation index.
  1378. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  1379. \def\singleindexer #1{\doind{\indexname}{#1}}
  1380. % like the previous two, but they put @code around the argument.
  1381. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  1382. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  1383. \def\indexdummies{%
  1384. % Take care of the plain tex accent commands.
  1385. \def\"{\realbackslash "}%
  1386. \def\`{\realbackslash `}%
  1387. \def\'{\realbackslash '}%
  1388. \def\^{\realbackslash ^}%
  1389. \def\~{\realbackslash ~}%
  1390. \def\={\realbackslash =}%
  1391. \def\b{\realbackslash b}%
  1392. \def\c{\realbackslash c}%
  1393. \def\d{\realbackslash d}%
  1394. \def\u{\realbackslash u}%
  1395. \def\v{\realbackslash v}%
  1396. \def\H{\realbackslash H}%
  1397. % Take care of the plain tex special European modified letters.
  1398. \def\oe{\realbackslash oe}%
  1399. \def\ae{\realbackslash ae}%
  1400. \def\aa{\realbackslash aa}%
  1401. \def\OE{\realbackslash OE}%
  1402. \def\AE{\realbackslash AE}%
  1403. \def\AA{\realbackslash AA}%
  1404. \def\o{\realbackslash o}%
  1405. \def\O{\realbackslash O}%
  1406. \def\l{\realbackslash l}%
  1407. \def\L{\realbackslash L}%
  1408. \def\ss{\realbackslash ss}%
  1409. % Take care of texinfo commands likely to appear in an index entry.
  1410. \def\_{{\realbackslash _}}%
  1411. \def\w{\realbackslash w }%
  1412. \def\bf{\realbackslash bf }%
  1413. \def\rm{\realbackslash rm }%
  1414. \def\sl{\realbackslash sl }%
  1415. \def\sf{\realbackslash sf}%
  1416. \def\tt{\realbackslash tt}%
  1417. \def\gtr{\realbackslash gtr}%
  1418. \def\less{\realbackslash less}%
  1419. \def\hat{\realbackslash hat}%
  1420. \def\char{\realbackslash char}%
  1421. \def\TeX{\realbackslash TeX}%
  1422. \def\dots{\realbackslash dots }%
  1423. \def\copyright{\realbackslash copyright }%
  1424. \def\tclose##1{\realbackslash tclose {##1}}%
  1425. \def\code##1{\realbackslash code {##1}}%
  1426. \def\samp##1{\realbackslash samp {##1}}%
  1427. \def\t##1{\realbackslash r {##1}}%
  1428. \def\r##1{\realbackslash r {##1}}%
  1429. \def\i##1{\realbackslash i {##1}}%
  1430. \def\b##1{\realbackslash b {##1}}%
  1431. \def\cite##1{\realbackslash cite {##1}}%
  1432. \def\key##1{\realbackslash key {##1}}%
  1433. \def\file##1{\realbackslash file {##1}}%
  1434. \def\var##1{\realbackslash var {##1}}%
  1435. \def\kbd##1{\realbackslash kbd {##1}}%
  1436. \def\dfn##1{\realbackslash dfn {##1}}%
  1437. \def\emph##1{\realbackslash emph {##1}}%
  1438. % \indexnofonts no-ops all font-change commands.
  1439. % This is used when outputting the strings to sort the index by.
  1440. \def\indexdummyfont#1{#1}
  1441. \def\indexdummytex{TeX}
  1442. \def\indexdummydots{...}
  1443. \def\indexnofonts{%
  1444. % Just ignore accents.
  1445. \let\"=\indexdummyfont
  1446. \let\`=\indexdummyfont
  1447. \let\'=\indexdummyfont
  1448. \let\^=\indexdummyfont
  1449. \let\~=\indexdummyfont
  1450. \let\==\indexdummyfont
  1451. \let\b=\indexdummyfont
  1452. \let\c=\indexdummyfont
  1453. \let\d=\indexdummyfont
  1454. \let\u=\indexdummyfont
  1455. \let\v=\indexdummyfont
  1456. \let\H=\indexdummyfont
  1457. % Take care of the plain tex special European modified letters.
  1458. \def\oe{oe}%
  1459. \def\ae{ae}%
  1460. \def\aa{aa}%
  1461. \def\OE{OE}%
  1462. \def\AE{AE}%
  1463. \def\AA{AA}%
  1464. \def\o{o}%
  1465. \def\O{O}%
  1466. \def\l{l}%
  1467. \def\L{L}%
  1468. \def\ss{ss}%
  1469. \let\w=\indexdummyfont
  1470. \let\t=\indexdummyfont
  1471. \let\r=\indexdummyfont
  1472. \let\i=\indexdummyfont
  1473. \let\b=\indexdummyfont
  1474. \let\emph=\indexdummyfont
  1475. \let\strong=\indexdummyfont
  1476. \let\cite=\indexdummyfont
  1477. \let\sc=\indexdummyfont
  1478. %Don't no-op \tt, since it isn't a user-level command
  1479. % and is used in the definitions of the active chars like <, >, |...
  1480. %\let\tt=\indexdummyfont
  1481. \let\tclose=\indexdummyfont
  1482. \let\code=\indexdummyfont
  1483. \let\file=\indexdummyfont
  1484. \let\samp=\indexdummyfont
  1485. \let\kbd=\indexdummyfont
  1486. \let\key=\indexdummyfont
  1487. \let\var=\indexdummyfont
  1488. \let\TeX=\indexdummytex
  1489. \let\dots=\indexdummydots
  1490. % To define \realbackslash, we must make \ not be an escape.
  1491. % We must first make another character (@) an escape
  1492. % so we do not become unable to do a definition.
  1493. {\catcode`\@=0 \catcode`\\=\other
  1494. @gdef@realbackslash{\}}
  1495. \let\indexbackslash=0  %overridden during \printindex.
  1496. \def\doind #1#2{%
  1497. {\count10=\lastpenalty %
  1498. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1499. \escapechar=`\\%
  1500. {\let\folio=0% Expand all macros now EXCEPT \folio
  1501. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  1502. % so it will be output as is; and it will print as backslash in the indx.
  1503. % Now process the index-string once, with all font commands turned off,
  1504. % to get the string to sort the index by.
  1505. {\indexnofonts
  1506. \xdef\temp1{#2}%
  1507. % Now produce the complete index entry.  We process the index-string again,
  1508. % this time with font commands expanded, to get what to print in the index.
  1509. \edef\temp{%
  1510. \write \csname#1indfile\endcsname{%
  1511. \realbackslash entry {\temp1}{\folio}{#2}}}%
  1512. \temp }%
  1513. }\penalty\count10}}
  1514. \def\dosubind #1#2#3{%
  1515. {\count10=\lastpenalty %
  1516. {\indexdummies % Must do this here, since \bf, etc expand at this stage
  1517. \escapechar=`\\%
  1518. {\let\folio=0%
  1519. \def\rawbackslashxx{\indexbackslash}%
  1520. % Now process the index-string once, with all font commands turned off,
  1521. % to get the string to sort the index by.
  1522. {\indexnofonts
  1523. \xdef\temp1{#2 #3}%
  1524. % Now produce the complete index entry.  We process the index-string again,
  1525. % this time with font commands expanded, to get what to print in the index.
  1526. \edef\temp{%
  1527. \write \csname#1indfile\endcsname{%
  1528. \realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
  1529. \temp }%
  1530. }\penalty\count10}}
  1531. % The index entry written in the file actually looks like
  1532. %  \entry {sortstring}{page}{topic}
  1533. %  \entry {sortstring}{page}{topic}{subtopic}
  1534. % The texindex program reads in these files and writes files
  1535. % containing these kinds of lines:
  1536. %  \initial {c}
  1537. %     before the first topic whose initial is c
  1538. %  \entry {topic}{pagelist}
  1539. %     for a topic that is used without subtopics
  1540. %  \primary {topic}
  1541. %     for the beginning of a topic that is used with subtopics
  1542. %  \secondary {subtopic}{pagelist}
  1543. %     for each subtopic.
  1544. % Define the user-accessible indexing commands
  1545. % @findex, @vindex, @kindex, @cindex.
  1546. \def\findex {\fnindex}
  1547. \def\kindex {\kyindex}
  1548. \def\cindex {\cpindex}
  1549. \def\vindex {\vrindex}
  1550. \def\tindex {\tpindex}
  1551. \def\pindex {\pgindex}
  1552. \def\cindexsub {\begingroup\obeylines\cindexsub}
  1553. {\obeylines %
  1554. \gdef\cindexsub "#1" #2^^M{\endgroup %
  1555. \dosubind{cp}{#2}{#1}}}
  1556. % Define the macros used in formatting output of the sorted index material.
  1557. % This is what you call to cause a particular index to get printed.
  1558. % Write
  1559. % @unnumbered Function Index
  1560. % @printindex fn
  1561. \def\printindex{\parsearg\doprintindex}
  1562. \def\doprintindex#1{%
  1563.   \tex
  1564.   \dobreak \chapheadingskip {10000}
  1565.   \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
  1566.   \catcode`\$=\other
  1567.   \catcode`\~=\other
  1568.   \indexbreaks
  1569.   % The following don't help, since the chars were translated
  1570.   % when the raw index was written, and their fonts were discarded
  1571.   % due to \indexnofonts.
  1572.   %\catcode`\"=\active
  1573.   %\catcode`\^=\active
  1574.   %\catcode`\_=\active
  1575.   %\catcode`\|=\active
  1576.   %\catcode`\<=\active
  1577.   %\catcode`\>=\active
  1578.   % %
  1579.   \def\indexbackslash{\rawbackslashxx}
  1580.   \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
  1581.   \begindoublecolumns
  1582.   % See if the index file exists and is nonempty.
  1583.   \openin 1 \jobname.#1s
  1584.   \ifeof 1
  1585.     % \enddoublecolumns gets confused if there is no text in the index,
  1586.     % and it loses the chapter title and the aux file entries for the
  1587.     % index.  The easiest way to prevent this problem is to make sure
  1588.     % there is some text.
  1589.     (Index is nonexistent)
  1590.     \else
  1591.     %
  1592.     % If the index file exists but is empty, then \openin leaves \ifeof
  1593.     % false.  We have to make TeX try to read something from the file, so
  1594.     % it can discover if there is anything in it.
  1595.     \read 1 to \temp
  1596.     \ifeof 1
  1597.       (Index is empty)
  1598.     \else
  1599.       \input \jobname.#1s
  1600.     \fi
  1601.   \fi
  1602.   \closein 1
  1603.   \enddoublecolumns
  1604.   \Etex
  1605. % These macros are used by the sorted index file itself.
  1606. % Change them to control the appearance of the index.
  1607. % Same as \bigskipamount except no shrink.
  1608. % \balancecolumns gets confused if there is any shrink.
  1609. \newskip\initialskipamount \initialskipamount 12pt plus4pt
  1610. \def\initial #1{%
  1611. {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  1612. \ifdim\lastskip<\initialskipamount
  1613. \removelastskip \penalty-200 \vskip \initialskipamount\fi
  1614. \line{\secbf#1\hfill}\kern 2pt\penalty10000}}
  1615. % This typesets a paragraph consisting of #1, dot leaders, and then #2
  1616. % flush to the right margin.  It is used for index and table of contents
  1617. % entries.  The paragraph is indented by \leftskip.
  1618. \def\entry #1#2{\begingroup
  1619.   % Start a new paragraph if necessary, so our assignments below can't
  1620.   % affect previous text.
  1621.   \par
  1622.   % Do not fill out the last line with white space.
  1623.   \parfillskip = 0in
  1624.   % No extra space above this paragraph.
  1625.   \parskip = 0in
  1626.   % Do not prefer a separate line ending with a hyphen to fewer lines.
  1627.   \finalhyphendemerits = 0
  1628.   % \hangindent is only relevant when the entry text and page number
  1629.   % don't both fit on one line.  In that case, bob suggests starting the
  1630.   % dots pretty far over on the line.  Unfortunately, a large
  1631.   % indentation looks wrong when the entry text itself is broken across
  1632.   % lines.  So we use a small indentation and put up with long leaders.
  1633.   % \hangafter is reset to 1 (which is the value we want) at the start
  1634.   % of each paragraph, so we need not do anything with that.
  1635.   \hangindent=2em
  1636.   % When the entry text needs to be broken, just fill out the first line
  1637.   % with blank space.
  1638.   \rightskip = 0pt plus1fil
  1639.   % Start a ``paragraph'' for the index entry so the line breaking
  1640.   % parameters we've set above will have an effect.
  1641.   \noindent
  1642.   % Insert the text of the index entry.  TeX will do line-breaking on it.
  1643.   #1%
  1644.   % The following is kluged to not output a line of dots in the index if
  1645.   % there are no page numbers.  The next person who breaks this will be
  1646.   % cursed by a Unix daemon.
  1647.   \def\tempa{{\rm }}%
  1648.   \def\tempb{#2}%
  1649.   \edef\tempc{\tempa}%
  1650.   \edef\tempd{\tempb}%
  1651.   \ifx\tempc\tempd\ \else%
  1652.     %
  1653.     % If we must, put the page number on a line of its own, and fill out
  1654.     % this line with blank space.  (The \hfil is overwhelmed with the
  1655.     % fill leaders glue in \indexdotfill if the page number does fit.)
  1656.     \hfil\penalty50
  1657.     \null\nobreak\indexdotfill % Have leaders before the page number.
  1658.     %
  1659.     % The `\ ' here is removed by the implicit \unskip that TeX does as
  1660.     % part of (the primitive) \par.  Without it, a spurious underfull
  1661.     % \hbox ensues.
  1662.     \ #2% The page number ends the paragraph.
  1663.   \fi%
  1664.   \par
  1665. \endgroup}
  1666. % Like \dotfill except takes at least 1 em.
  1667. \def\indexdotfill{\cleaders
  1668.   \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
  1669. \def\primary #1{\line{#1\hfil}}
  1670. \newskip\secondaryindent \secondaryindent=0.5cm
  1671. \def\secondary #1#2{
  1672. {\parfillskip=0in \parskip=0in
  1673. \hangindent =1in \hangafter=1
  1674. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
  1675. %% Define two-column mode, which is used in indexes.
  1676. %% Adapted from the TeXbook, page 416.
  1677. \catcode `\@=11
  1678. \newbox\partialpage
  1679. \newdimen\doublecolumnhsize
  1680. \def\begindoublecolumns{\begingroup
  1681.   % Grab any single-column material above us.
  1682.   \output = {\global\setbox\partialpage
  1683.     =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}%
  1684.   \eject
  1685.   % Now switch to the double-column output routine.
  1686.   \output={\doublecolumnout}%
  1687.   % Change the page size parameters.  We could do this once outside this
  1688.   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
  1689.   % format, but then we repeat the same computation.  Repeating a couple
  1690.   % of assignments once per index is clearly meaningless for the
  1691.   % execution time, so we may as well do it once.
  1692.   % First we halve the line length, less a little for the gutter between
  1693.   % the columns.  We compute the gutter based on the line length, so it
  1694.   % changes automatically with the paper format.  The magic constant
  1695.   % below is chosen so that the gutter has the same value (well, +- <
  1696.   % 1pt) as it did when we hard-coded it.
  1697.   % We put the result in a separate register, \doublecolumhsize, so we
  1698.   % can restore it in \pagesofar, after \hsize itself has (potentially)
  1699.   % been clobbered.
  1700.   \doublecolumnhsize = \hsize
  1701.     \advance\doublecolumnhsize by -.04154\hsize
  1702.     \divide\doublecolumnhsize by 2
  1703.   \hsize = \doublecolumnhsize
  1704.   % Double the \vsize as well.  (We don't need a separate register here,
  1705.   % since nobody clobbers \vsize.)
  1706.   \vsize = 2\vsize
  1707.   \doublecolumnpagegoal
  1708. \def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage}
  1709. \def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  1710.   \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage
  1711.   \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1}
  1712.   \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3}
  1713.   \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  1714.   \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
  1715. \def\doublecolumnpagegoal{%
  1716.   \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@
  1717. \def\pagesofar{\unvbox\partialpage %
  1718.   \hsize=\doublecolumnhsize % have to restore this since output routine
  1719.   \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
  1720. \def\doublecolumnout{%
  1721.   \setbox5=\copy255
  1722.   {\vbadness=10000 \doublecolumnsplit}
  1723.   \ifvbox255
  1724.     \setbox0=\vtop to\dimen@{\unvbox0}
  1725.     \setbox2=\vtop to\dimen@{\unvbox2}
  1726.     \onepageout\pagesofar \unvbox255 \penalty\outputpenalty
  1727.   \else
  1728.     \setbox0=\vbox{\unvbox5}
  1729.     \ifvbox0
  1730.       \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  1731.       \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth
  1732.       {\vbadness=10000
  1733.     \loop \global\setbox5=\copy0
  1734.           \setbox1=\vsplit5 to\dimen@
  1735.           \setbox3=\vsplit5 to\dimen@
  1736.           \ifvbox5 \global\advance\dimen@ by1pt \repeat
  1737.         \setbox0=\vbox to\dimen@{\unvbox1}
  1738.         \setbox2=\vbox to\dimen@{\unvbox3}
  1739.         \global\setbox\partialpage=\vbox{\pagesofar}
  1740.         \doublecolumnpagegoal
  1741.       }
  1742.     \fi
  1743.   \fi
  1744. \catcode `\@=\other
  1745. \message{sectioning,}
  1746. % Define chapters, sections, etc.
  1747. \newcount \chapno
  1748. \newcount \secno        \secno=0
  1749. \newcount \subsecno     \subsecno=0
  1750. \newcount \subsubsecno  \subsubsecno=0
  1751. % This counter is funny since it counts through charcodes of letters A, B, ...
  1752. \newcount \appendixno  \appendixno = `\@
  1753. \def\appendixletter{\char\the\appendixno}
  1754. \newwrite \contentsfile
  1755. % This is called from \setfilename.
  1756. \def\opencontents{\openout \contentsfile = \jobname.toc}
  1757. % Each @chapter defines this as the name of the chapter.
  1758. % page headings and footings can use it.  @section does likewise
  1759. \def\thischapter{} \def\thissection{}
  1760. \def\seccheck#1{\if \pageno<0 %
  1761. \errmessage{@#1 not allowed after generating table of contents}\fi
  1762. \def\chapternofonts{%
  1763. \let\rawbackslash=\relax%
  1764. \let\frenchspacing=\relax%
  1765. \def\result{\realbackslash result}
  1766. \def\equiv{\realbackslash equiv}
  1767. \def\expansion{\realbackslash expansion}
  1768. \def\print{\realbackslash print}
  1769. \def\TeX{\realbackslash TeX}
  1770. \def\dots{\realbackslash dots}
  1771. \def\copyright{\realbackslash copyright}
  1772. \def\tt{\realbackslash tt}
  1773. \def\bf{\realbackslash bf }
  1774. \def\w{\realbackslash w}
  1775. \def\less{\realbackslash less}
  1776. \def\gtr{\realbackslash gtr}
  1777. \def\hat{\realbackslash hat}
  1778. \def\char{\realbackslash char}
  1779. \def\tclose##1{\realbackslash tclose {##1}}
  1780. \def\code##1{\realbackslash code {##1}}
  1781. \def\samp##1{\realbackslash samp {##1}}
  1782. \def\r##1{\realbackslash r {##1}}
  1783. \def\b##1{\realbackslash b {##1}}
  1784. \def\key##1{\realbackslash key {##1}}
  1785. \def\file##1{\realbackslash file {##1}}
  1786. \def\kbd##1{\realbackslash kbd {##1}}
  1787. % These are redefined because @smartitalic wouldn't work inside xdef.
  1788. \def\i##1{\realbackslash i {##1}}
  1789. \def\cite##1{\realbackslash cite {##1}}
  1790. \def\var##1{\realbackslash var {##1}}
  1791. \def\emph##1{\realbackslash emph {##1}}
  1792. \def\dfn##1{\realbackslash dfn {##1}}
  1793. \newcount\absseclevel % used to calculate proper heading level
  1794. \newcount\secbase\secbase=0 % @raise/lowersections modify this count
  1795. % @raisesections: treat @section as chapter, @subsection as section, etc.
  1796. \def\raisesections{\global\advance\secbase by -1}
  1797. \let\up=\raisesections % original BFox name
  1798. % @lowersections: treat @chapter as section, @section as subsection, etc.
  1799. \def\lowersections{\global\advance\secbase by 1}
  1800. \let\down=\lowersections % original BFox name
  1801. % Choose a numbered-heading macro
  1802. % #1 is heading level if unmodified by @raisesections or @lowersections
  1803. % #2 is text for heading
  1804. \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  1805. \ifcase\absseclevel
  1806.   \chapterzzz{#2}
  1807.   \seczzz{#2}
  1808.   \numberedsubseczzz{#2}
  1809.   \numberedsubsubseczzz{#2}
  1810. \else
  1811.   \ifnum \absseclevel<0
  1812.     \chapterzzz{#2}
  1813.   \else
  1814.     \numberedsubsubseczzz{#2}
  1815.   \fi
  1816. % like \numhead, but chooses appendix heading levels
  1817. \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  1818. \ifcase\absseclevel
  1819.   \appendixzzz{#2}
  1820.   \appendixsectionzzz{#2}
  1821.   \appendixsubseczzz{#2}
  1822.   \appendixsubsubseczzz{#2}
  1823. \else
  1824.   \ifnum \absseclevel<0
  1825.     \appendixzzz{#2}
  1826.   \else
  1827.     \appendixsubsubseczzz{#2}
  1828.   \fi
  1829. % like \numhead, but chooses numberless heading levels
  1830. \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  1831. \ifcase\absseclevel
  1832.   \unnumberedzzz{#2}
  1833.   \unnumberedseczzz{#2}
  1834.   \unnumberedsubseczzz{#2}
  1835.   \unnumberedsubsubseczzz{#2}
  1836. \else
  1837.   \ifnum \absseclevel<0
  1838.     \unnumberedzzz{#2}
  1839.   \else
  1840.     \unnumberedsubsubseczzz{#2}
  1841.   \fi
  1842. \def\thischaptername{No Chapter Title}
  1843. \outer\def\chapter{\parsearg\chapteryyy}
  1844. \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
  1845. \def\chapterzzz #1{\seccheck{chapter}%
  1846. \secno=0 \subsecno=0 \subsubsecno=0
  1847. \global\advance \chapno by 1 \message{Chapter \the\chapno}%
  1848. \chapmacro {#1}{\the\chapno}%
  1849. \gdef\thissection{#1}%
  1850. \gdef\thischaptername{#1}%
  1851. % We don't substitute the actual chapter name into \thischapter
  1852. % because we don't want its macros evaluated now.
  1853. \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
  1854. {\chapternofonts%
  1855. \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
  1856. \escapechar=`\\%
  1857. \write \contentsfile \temp  %
  1858. \donoderef %
  1859. \global\let\section = \numberedsec
  1860. \global\let\subsection = \numberedsubsec
  1861. \global\let\subsubsection = \numberedsubsubsec
  1862. \outer\def\appendix{\parsearg\appendixyyy}
  1863. \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
  1864. \def\appendixzzz #1{\seccheck{appendix}%
  1865. \secno=0 \subsecno=0 \subsubsecno=0
  1866. \global\advance \appendixno by 1 \message{Appendix \appendixletter}%
  1867. \chapmacro {#1}{\putwordAppendix{} \appendixletter}%
  1868. \gdef\thissection{#1}%
  1869. \gdef\thischaptername{#1}%
  1870. \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
  1871. {\chapternofonts%
  1872. \edef\temp{{\realbackslash chapentry
  1873.   {#1}{\putwordAppendix{} \appendixletter}{\noexpand\folio}}}%
  1874. \escapechar=`\\%
  1875. \write \contentsfile \temp  %
  1876. \appendixnoderef %
  1877. \global\let\section = \appendixsec
  1878. \global\let\subsection = \appendixsubsec
  1879. \global\let\subsubsection = \appendixsubsubsec
  1880. \outer\def\top{\parsearg\unnumberedyyy}
  1881. \outer\def\unnumbered{\parsearg\unnumberedyyy}
  1882. \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
  1883. \def\unnumberedzzz #1{\seccheck{unnumbered}%
  1884. \secno=0 \subsecno=0 \subsubsecno=0
  1885. % This used to be simply \message{#1}, but TeX fully expands the
  1886. % argument to \message.  Therefore, if #1 contained @-commands, TeX
  1887. % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
  1888. % expanded @cite (which turns out to cause errors because \cite is meant
  1889. % to be executed, not expanded).
  1890. % Anyway, we don't want the fully-expanded definition of @cite to appear
  1891. % as a result of the \message, we just want `@cite' itself.  We use
  1892. % \the<toks register> to achieve this: TeX expands \the<toks> only once,
  1893. % simply yielding the contents of the <toks register>.
  1894. \toks0 = {#1}\message{(\the\toks0)}%
  1895. \unnumbchapmacro {#1}%
  1896. \gdef\thischapter{#1}\gdef\thissection{#1}%
  1897. {\chapternofonts%
  1898. \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
  1899. \escapechar=`\\%
  1900. \write \contentsfile \temp  %
  1901. \unnumbnoderef %
  1902. \global\let\section = \unnumberedsec
  1903. \global\let\subsection = \unnumberedsubsec
  1904. \global\let\subsubsection = \unnumberedsubsubsec
  1905. \outer\def\numberedsec{\parsearg\secyyy}
  1906. \def\secyyy #1{\numhead1{#1}} % normally calls seczzz
  1907. \def\seczzz #1{\seccheck{section}%
  1908. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1909. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  1910. {\chapternofonts%
  1911. \edef\temp{{\realbackslash secentry %
  1912. {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
  1913. \escapechar=`\\%
  1914. \write \contentsfile \temp %
  1915. \donoderef %
  1916. \penalty 10000 %
  1917. \outer\def\appenixsection{\parsearg\appendixsecyyy}
  1918. \outer\def\appendixsec{\parsearg\appendixsecyyy}
  1919. \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
  1920. \def\appendixsectionzzz #1{\seccheck{appendixsection}%
  1921. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  1922. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  1923. {\chapternofonts%
  1924. \edef\temp{{\realbackslash secentry %
  1925. {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
  1926. \escapechar=`\\%
  1927. \write \contentsfile \temp %
  1928. \appendixnoderef %
  1929. \penalty 10000 %
  1930. \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
  1931. \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
  1932. \def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
  1933. \plainsecheading {#1}\gdef\thissection{#1}%
  1934. {\chapternofonts%
  1935. \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
  1936. \escapechar=`\\%
  1937. \write \contentsfile \temp %
  1938. \unnumbnoderef %
  1939. \penalty 10000 %
  1940. \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
  1941. \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
  1942. \def\numberedsubseczzz #1{\seccheck{subsection}%
  1943. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1944. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  1945. {\chapternofonts%
  1946. \edef\temp{{\realbackslash subsecentry %
  1947. {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1948. \escapechar=`\\%
  1949. \write \contentsfile \temp %
  1950. \donoderef %
  1951. \penalty 10000 %
  1952. \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
  1953. \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
  1954. \def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
  1955. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  1956. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  1957. {\chapternofonts%
  1958. \edef\temp{{\realbackslash subsecentry %
  1959. {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
  1960. \escapechar=`\\%
  1961. \write \contentsfile \temp %
  1962. \appendixnoderef %
  1963. \penalty 10000 %
  1964. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
  1965. \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
  1966. \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
  1967. \plainsecheading {#1}\gdef\thissection{#1}%
  1968. {\chapternofonts%
  1969. \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
  1970. \escapechar=`\\%
  1971. \write \contentsfile \temp %
  1972. \unnumbnoderef %
  1973. \penalty 10000 %
  1974. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
  1975. \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
  1976. \def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
  1977. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1978. \subsubsecheading {#1}
  1979.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1980. {\chapternofonts%
  1981. \edef\temp{{\realbackslash subsubsecentry %
  1982.   {#1}
  1983.   {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
  1984.   {\noexpand\folio}}}%
  1985. \escapechar=`\\%
  1986. \write \contentsfile \temp %
  1987. \donoderef %
  1988. \penalty 10000 %
  1989. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
  1990. \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
  1991. \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
  1992. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  1993. \subsubsecheading {#1}
  1994.   {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  1995. {\chapternofonts%
  1996. \edef\temp{{\realbackslash subsubsecentry{#1}%
  1997.   {\appendixletter}
  1998.   {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
  1999. \escapechar=`\\%
  2000. \write \contentsfile \temp %
  2001. \appendixnoderef %
  2002. \penalty 10000 %
  2003. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
  2004. \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
  2005. \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
  2006. \plainsecheading {#1}\gdef\thissection{#1}%
  2007. {\chapternofonts%
  2008. \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
  2009. \escapechar=`\\%
  2010. \write \contentsfile \temp %
  2011. \unnumbnoderef %
  2012. \penalty 10000 %
  2013. % These are variants which are not "outer", so they can appear in @ifinfo.
  2014. % Actually, they should now be obsolete; ordinary section commands should work.
  2015. \def\infotop{\parsearg\unnumberedzzz}
  2016. \def\infounnumbered{\parsearg\unnumberedzzz}
  2017. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  2018. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  2019. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  2020. \def\infoappendix{\parsearg\appendixzzz}
  2021. \def\infoappendixsec{\parsearg\appendixseczzz}
  2022. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  2023. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  2024. \def\infochapter{\parsearg\chapterzzz}
  2025. \def\infosection{\parsearg\sectionzzz}
  2026. \def\infosubsection{\parsearg\subsectionzzz}
  2027. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  2028. % These macros control what the section commands do, according
  2029. % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
  2030. % Define them by default for a numbered chapter.
  2031. \global\let\section = \numberedsec
  2032. \global\let\subsection = \numberedsubsec
  2033. \global\let\subsubsection = \numberedsubsubsec
  2034. % Define @majorheading, @heading and @subheading
  2035. % NOTE on use of \vbox for chapter headings, section headings, and
  2036. % such:
  2037. %    1) We use \vbox rather than the earlier \line to permit
  2038. %       overlong headings to fold.
  2039. %    2) \hyphenpenalty is set to 10000 because hyphenation in a
  2040. %       heading is obnoxious; this forbids it.
  2041. %       3) Likewise, headings look best if no \parindent is used, and
  2042. %          if justification is not attempted.  Hence \raggedright.
  2043. \def\majorheading{\parsearg\majorheadingzzz}
  2044. \def\majorheadingzzz #1{%
  2045. {\advance\chapheadingskip by 10pt \chapbreak }%
  2046. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2047.                   \parindent=0pt\raggedright
  2048.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  2049. \def\chapheading{\parsearg\chapheadingzzz}
  2050. \def\chapheadingzzz #1{\chapbreak %
  2051. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2052.                   \parindent=0pt\raggedright
  2053.                   \rm #1\hfill}}\bigskip \par\penalty 200}
  2054. \def\heading{\parsearg\secheadingi}
  2055. \def\subheading{\parsearg\subsecheadingi}
  2056. \def\subsubheading{\parsearg\subsubsecheadingi}
  2057. % These macros generate a chapter, section, etc. heading only
  2058. % (including whitespace, linebreaking, etc. around it),
  2059. % given all the information in convenient, parsed form.
  2060. %%% Args are the skip and penalty (usually negative)
  2061. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  2062. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  2063. %%% Define plain chapter starts, and page on/off switching for it
  2064. % Parameter controlling skip before chapter headings (if needed)
  2065. \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
  2066. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  2067. \def\chappager{\par\vfill\supereject}
  2068. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  2069. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  2070. \def\CHAPPAGoff{
  2071. \global\let\pchapsepmacro=\chapbreak
  2072. \global\let\pagealignmacro=\chappager}
  2073. \def\CHAPPAGon{
  2074. \global\let\pchapsepmacro=\chappager
  2075. \global\let\pagealignmacro=\chappager
  2076. \global\def\HEADINGSon{\HEADINGSsingle}}
  2077. \def\CHAPPAGodd{
  2078. \global\let\pchapsepmacro=\chapoddpage
  2079. \global\let\pagealignmacro=\chapoddpage
  2080. \global\def\HEADINGSon{\HEADINGSdouble}}
  2081. \CHAPPAGon
  2082. \def\CHAPFplain{
  2083. \global\let\chapmacro=\chfplain
  2084. \global\let\unnumbchapmacro=\unnchfplain}
  2085. \def\chfplain #1#2{%
  2086.   \pchapsepmacro
  2087.     \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2088.                      \parindent=0pt\raggedright
  2089.                      \rm #2\enspace #1}%
  2090.   \bigskip
  2091.   \penalty5000
  2092. \def\unnchfplain #1{%
  2093. \pchapsepmacro %
  2094. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2095.                   \parindent=0pt\raggedright
  2096.                   \rm #1\hfill}}\bigskip \par\penalty 10000 %
  2097. \CHAPFplain % The default
  2098. \def\unnchfopen #1{%
  2099. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2100.                        \parindent=0pt\raggedright
  2101.                        \rm #1\hfill}}\bigskip \par\penalty 10000 %
  2102. \def\chfopen #1#2{\chapoddpage {\chapfonts
  2103. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  2104. \par\penalty 5000 %
  2105. \def\CHAPFopen{
  2106. \global\let\chapmacro=\chfopen
  2107. \global\let\unnumbchapmacro=\unnchfopen}
  2108. % Parameter controlling skip before section headings.
  2109. \newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
  2110. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  2111. \newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
  2112. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  2113. % @paragraphindent  is defined for the Info formatting commands only.
  2114. \let\paragraphindent=\comment
  2115. % Section fonts are the base font at magstep2, which produces
  2116. % a size a bit more than 14 points in the default situation.
  2117. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
  2118. \def\plainsecheading #1{\secheadingi {#1}}
  2119. \def\secheadingi #1{{\advance \secheadingskip by \parskip %
  2120. \secheadingbreak}%
  2121. {\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2122.                  \parindent=0pt\raggedright
  2123.                  \rm #1\hfill}}%
  2124. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  2125. % Subsection fonts are the base font at magstep1,
  2126. % which produces a size of 12 points.
  2127. \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
  2128. \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  2129. \subsecheadingbreak}%
  2130. {\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2131.                      \parindent=0pt\raggedright
  2132.                      \rm #1\hfill}}%
  2133. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
  2134. \def\subsubsecfonts{\subsecfonts} % Maybe this should change:
  2135.                   % Perhaps make sssec fonts scaled
  2136.                   % magstep half
  2137. \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
  2138. \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
  2139. \subsecheadingbreak}%
  2140. {\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2141.                        \parindent=0pt\raggedright
  2142.                        \rm #1\hfill}}%
  2143. \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
  2144. \message{toc printing,}
  2145. % Finish up the main text and prepare to read what we've written
  2146. % to \contentsfile.
  2147. \newskip\contentsrightmargin \contentsrightmargin=1in
  2148. \def\startcontents#1{%
  2149.    \pagealignmacro
  2150.    \immediate\closeout \contentsfile
  2151.    \ifnum \pageno>0
  2152.       \pageno = -1        % Request roman numbered pages.
  2153.    \fi
  2154.    % Don't need to put `Contents' or `Short Contents' in the headline.
  2155.    % It is abundantly clear what they are.
  2156.    \unnumbchapmacro{#1}\def\thischapter{}%
  2157.    \begingroup           % Set up to handle contents files properly.
  2158.       \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
  2159.       \raggedbottom             % Worry more about breakpoints than the bottom.
  2160.       \advance\hsize by -\contentsrightmargin % Don't use the full line length.
  2161. % Normal (long) toc.
  2162. \outer\def\contents{%
  2163.    \startcontents{\putwordTableofContents}%
  2164.       \input \jobname.toc
  2165.    \endgroup
  2166.    \vfill \eject
  2167. % And just the chapters.
  2168. \outer\def\summarycontents{%
  2169.    \startcontents{\putwordShortContents}%
  2170.       %
  2171.       \let\chapentry = \shortchapentry
  2172.       \let\unnumbchapentry = \shortunnumberedentry
  2173.       % We want a true roman here for the page numbers.
  2174.       \secfonts
  2175.       \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
  2176.       \rm
  2177.       \advance\baselineskip by 1pt % Open it up a little.
  2178.       \def\secentry ##1##2##3##4{}
  2179.       \def\unnumbsecentry ##1##2{}
  2180.       \def\subsecentry ##1##2##3##4##5{}
  2181.       \def\unnumbsubsecentry ##1##2{}
  2182.       \def\subsubsecentry ##1##2##3##4##5##6{}
  2183.       \def\unnumbsubsubsecentry ##1##2{}
  2184.       \input \jobname.toc
  2185.    \endgroup
  2186.    \vfill \eject
  2187. \let\shortcontents = \summarycontents
  2188. % These macros generate individual entries in the table of contents.
  2189. % The first argument is the chapter or section name.
  2190. % The last argument is the page number.
  2191. % The arguments in between are the chapter number, section number, ...
  2192. % Chapter-level things, for both the long and short contents.
  2193. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  2194. % See comments in \dochapentry re vbox and related settings
  2195. \def\shortchapentry#1#2#3{%
  2196.   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
  2197. % Typeset the label for a chapter or appendix for the short contents.
  2198. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
  2199. % We could simplify the code here by writing out an \appendixentry
  2200. % command in the toc file for appendices, instead of using \chapentry
  2201. % for both, but it doesn't seem worth it.
  2202. \setbox0 = \hbox{\shortcontrm \putwordAppendix }
  2203. \newdimen\shortappendixwidth \shortappendixwidth = \wd0
  2204. \def\shortchaplabel#1{%
  2205.   % We typeset #1 in a box of constant width, regardless of the text of
  2206.   % #1, so the chapter titles will come out aligned.
  2207.   \setbox0 = \hbox{#1}%
  2208.   \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
  2209.   % This space should be plenty, since a single number is .5em, and the
  2210.   % widest letter (M) is 1em, at least in the Computer Modern fonts.
  2211.   % (This space doesn't include the extra space that gets added after
  2212.   % the label; that gets put in in \shortchapentry above.)
  2213.   \advance\dimen0 by 1.1em
  2214.   \hbox to \dimen0{#1\hfil}%
  2215. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  2216. \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
  2217. % Sections.
  2218. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  2219. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  2220. % Subsections.
  2221. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  2222. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  2223. % And subsubsections.
  2224. \def\subsubsecentry#1#2#3#4#5#6{%
  2225.   \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  2226. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  2227. % This parameter controls the indentation of the various levels.
  2228. \newdimen\tocindent \tocindent = 3pc
  2229. % Now for the actual typesetting. In all these, #1 is the text and #2 is the
  2230. % page number.
  2231. % If the toc has to be broken over pages, we would want to be at chapters
  2232. % if at all possible; hence the \penalty.
  2233. \def\dochapentry#1#2{%
  2234.    \penalty-300 \vskip\baselineskip
  2235.    \begingroup
  2236.      \chapentryfonts
  2237.      \tocentry{#1}{\dopageno{#2}}%
  2238.    \endgroup
  2239.    \nobreak\vskip .25\baselineskip
  2240. \def\dosecentry#1#2{\begingroup
  2241.   \secentryfonts \leftskip=\tocindent
  2242.   \tocentry{#1}{\dopageno{#2}}%
  2243. \endgroup}
  2244. \def\dosubsecentry#1#2{\begingroup
  2245.   \subsecentryfonts \leftskip=2\tocindent
  2246.   \tocentry{#1}{\dopageno{#2}}%
  2247. \endgroup}
  2248. \def\dosubsubsecentry#1#2{\begingroup
  2249.   \subsubsecentryfonts \leftskip=3\tocindent
  2250.   \tocentry{#1}{\dopageno{#2}}%
  2251. \endgroup}
  2252. % Final typesetting of a toc entry; we use the same \entry macro as for
  2253. % the index entries, but we want to suppress hyphenation here.  (We
  2254. % can't do that in the \entry macro, since index entries might consist
  2255. % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
  2256. \def\tocentry#1#2{\begingroup
  2257.   \hyphenpenalty = 10000
  2258.   \entry{#1}{#2}%
  2259. \endgroup}
  2260. % Space between chapter (or whatever) number and the title.
  2261. \def\labelspace{\hskip1em \relax}
  2262. \def\dopageno#1{{\rm #1}}
  2263. \def\doshortpageno#1{{\rm #1}}
  2264. \def\chapentryfonts{\secfonts \rm}
  2265. \def\secentryfonts{\textfonts}
  2266. \let\subsecentryfonts = \textfonts
  2267. \let\subsubsecentryfonts = \textfonts
  2268. \message{environments,}
  2269. % Since these characters are used in examples, it should be an even number of
  2270. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  2271. % Furthermore, these definitions must come after we define our fonts.
  2272. \newbox\dblarrowbox    \newbox\longdblarrowbox
  2273. \newbox\pushcharbox    \newbox\bullbox
  2274. \newbox\equivbox       \newbox\errorbox
  2275. \let\ptexequiv = \equiv
  2276. %{\tentt
  2277. %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  2278. %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  2279. %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  2280. %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  2281. % Adapted from the manmac format (p.420 of TeXbook)
  2282. %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  2283. %                                      depth .1ex\hfil}
  2284. \def\point{$\star$}
  2285. \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
  2286. \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
  2287. \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
  2288. \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
  2289. % Adapted from the TeXbook's \boxit.
  2290. {\tentt \global\dimen0 = 3em}% Width of the box.
  2291. \dimen2 = .55pt % Thickness of rules
  2292. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  2293. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  2294. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  2295.    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  2296.    \advance\hsize by -2\dimen2 % Rules.
  2297.    \vbox{
  2298.       \hrule height\dimen2
  2299.       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
  2300.          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  2301.          \kern3pt\vrule width\dimen2}% Space to right.
  2302.       \hrule height\dimen2}
  2303.     \hfil}
  2304. % The @error{} command.
  2305. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  2306. % @tex ... @end tex    escapes into raw Tex temporarily.
  2307. % One exception: @ is still an escape character, so that @end tex works.
  2308. % But \@ or @@ will get a plain tex @ character.
  2309. \def\tex{\begingroup
  2310. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  2311. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  2312. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  2313. \catcode `\%=14
  2314. \catcode 43=12
  2315. \catcode`\"=12
  2316. \catcode`\==12
  2317. \catcode`\|=12
  2318. \catcode`\<=12
  2319. \catcode`\>=12
  2320. \escapechar=`\\
  2321. \let\~=\ptextilde
  2322. \let\{=\ptexlbrace
  2323. \let\}=\ptexrbrace
  2324. \let\.=\ptexdot
  2325. \let\*=\ptexstar
  2326. \let\dots=\ptexdots
  2327. \def\@{@}%
  2328. \let\bullet=\ptexbullet
  2329. \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
  2330. \let\L=\ptexL
  2331. \let\Etex=\endgroup}
  2332. % Define @lisp ... @endlisp.
  2333. % @lisp does a \begingroup so it can rebind things,
  2334. % including the definition of @endlisp (which normally is erroneous).
  2335. % Amount to narrow the margins by for @lisp.
  2336. \newskip\lispnarrowing \lispnarrowing=0.4in
  2337. % This is the definition that ^^M gets inside @lisp, @example, and other
  2338. % such environments.  \null is better than a space, since it doesn't
  2339. % have any width.
  2340. \def\lisppar{\null\endgraf}
  2341. % Make each space character in the input produce a normal interword
  2342. % space in the output.  Don't allow a line break at this space, as this
  2343. % is used only in environments like @example, where each line of input
  2344. % should produce a line of output anyway.
  2345. {\obeyspaces %
  2346. \gdef\sepspaces{\obeyspaces\let =\tie}}
  2347. % Define \obeyedspace to be our active space, whatever it is.  This is
  2348. % for use in \parsearg.
  2349. {\sepspaces%
  2350. \global\let\obeyedspace= }
  2351. % This space is always present above and below environments.
  2352. \newskip\envskipamount \envskipamount = 0pt
  2353. % Make spacing and below environment symmetrical.  We use \parskip here
  2354. % to help in doing that, since in @example-like environments \parskip
  2355. % is reset to zero; thus the \afterenvbreak inserts no space -- but the
  2356. % start of the next paragraph will insert \parskip
  2357. \def\aboveenvbreak{{\advance\envskipamount by \parskip
  2358. \endgraf \ifdim\lastskip<\envskipamount
  2359. \removelastskip \penalty-50 \vskip\envskipamount \fi}}
  2360. \let\afterenvbreak = \aboveenvbreak
  2361. % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
  2362. \let\nonarrowing=\relax
  2363. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2364. % \cartouche: draw rectangle w/rounded corners around argument
  2365. \font\circle=lcircle10
  2366. \newdimen\circthick
  2367. \newdimen\cartouter\newdimen\cartinner
  2368. \newskip\normbskip\newskip\normpskip\newskip\normlskip
  2369. \circthick=\fontdimen8\circle
  2370. \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  2371. \def\ctr{{\hskip 6pt\circle\char'010}}
  2372. \def\cbl{{\circle\char'012\hskip -6pt}}
  2373. \def\cbr{{\hskip 6pt\circle\char'011}}
  2374. \def\carttop{\hbox to \cartouter{\hskip\lskip
  2375.     \ctl\leaders\hrule height\circthick\hfil\ctr
  2376.     \hskip\rskip}}
  2377. \def\cartbot{\hbox to \cartouter{\hskip\lskip
  2378.     \cbl\leaders\hrule height\circthick\hfil\cbr
  2379.     \hskip\rskip}}
  2380. \newskip\lskip\newskip\rskip
  2381. \long\def\cartouche{%
  2382. \begingroup
  2383.     \lskip=\leftskip \rskip=\rightskip
  2384.     \leftskip=0pt\rightskip=0pt %we want these *outside*.
  2385.     \cartinner=\hsize \advance\cartinner by-\lskip
  2386.                \advance\cartinner by-\rskip
  2387.     \cartouter=\hsize
  2388.     \advance\cartouter by 18pt % allow for 3pt kerns on either
  2389. %                     side, and for 6pt waste from
  2390. %                     each corner char
  2391.     \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
  2392.     % Flag to tell @lisp, etc., not to narrow margin.
  2393.     \let\nonarrowing=\comment
  2394.     \vbox\bgroup
  2395.         \baselineskip=0pt\parskip=0pt\lineskip=0pt
  2396.         \carttop
  2397.         \hbox\bgroup
  2398.             \hskip\lskip
  2399.             \vrule\kern3pt
  2400.             \vbox\bgroup
  2401.                 \hsize=\cartinner
  2402.                 \kern3pt
  2403.                 \begingroup
  2404.                     \baselineskip=\normbskip
  2405.                     \lineskip=\normlskip
  2406.                     \parskip=\normpskip
  2407.                     \vskip -\parskip
  2408. \def\Ecartouche{%
  2409.                 \endgroup
  2410.                 \kern3pt
  2411.             \egroup
  2412.             \kern3pt\vrule
  2413.             \hskip\rskip
  2414.         \egroup
  2415.         \cartbot
  2416.     \egroup
  2417. \endgroup
  2418. % This macro is called at the beginning of all the @example variants,
  2419. % inside a group.
  2420. \def\nonfillstart{%
  2421.   \aboveenvbreak
  2422.   \inENV % This group ends at the end of the body
  2423.   \hfuzz = 12pt % Don't be fussy
  2424.   \sepspaces % Make spaces be word-separators rather than space tokens.
  2425.   \singlespace
  2426.   \let\par = \lisppar % don't ignore blank lines
  2427.   \obeylines % each line of input is a line of output
  2428.   \parskip = 0pt
  2429.   \parindent = 0pt
  2430.   \emergencystretch = 0pt % don't try to avoid overfull boxes
  2431.   % @cartouche defines \nonarrowing to inhibit narrowing
  2432.   % at next level down.
  2433.   \ifx\nonarrowing\relax
  2434.     \advance \leftskip by \lispnarrowing
  2435.     \exdentamount=\lispnarrowing
  2436.     \let\exdent=\nofillexdent
  2437.     \let\nonarrowing=\relax
  2438.   \fi
  2439. % To ending an @example-like environment, we first end the paragraph
  2440. % (via \afterenvbreak's vertical glue), and then the group.  That way we
  2441. % keep the zero \parskip that the environments set -- \parskip glue
  2442. % will be inserted at the beginning of the next paragraph in the
  2443. % document, after the environment.
  2444. \def\nonfillfinish{\afterenvbreak\endgroup}%
  2445. % This macro is
  2446. \def\lisp{\begingroup
  2447.   \nonfillstart
  2448.   \let\Elisp = \nonfillfinish
  2449.   \tt
  2450.   \rawbackslash % have \ input char produce \ char from current font
  2451.   \gobble
  2452. % Define the \E... control sequence only if we are inside the
  2453. % environment, so the error checking in \end will work.
  2454. % We must call \lisp last in the definition, since it reads the
  2455. % return following the @example (or whatever) command.
  2456. \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
  2457. \def\smallexample{\begingroup \def\Esmallexample{\nonfillfinish\endgroup}\lisp}
  2458. \def\smalllisp{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
  2459. % @smallexample and @smalllisp.  This is not used unless the @smallbook
  2460. % command is given.  Originally contributed by Pavel@xerox.
  2461. \def\smalllispx{\begingroup
  2462.   \nonfillstart
  2463.   \let\Esmalllisp = \nonfillfinish
  2464.   \let\Esmallexample = \nonfillfinish
  2465.   % Smaller interline space and fonts for small examples.
  2466.   \setleading{10pt}%
  2467.   \indexfonts \tt
  2468.   \rawbackslash % make \ output the \ character from the current font (tt)
  2469.   \gobble
  2470. % This is @display; same as @lisp except use roman font.
  2471. \def\display{\begingroup
  2472.   \nonfillstart
  2473.   \let\Edisplay = \nonfillfinish
  2474.   \gobble
  2475. % This is @format; same as @display except don't narrow margins.
  2476. \def\format{\begingroup
  2477.   \let\nonarrowing = t
  2478.   \nonfillstart
  2479.   \let\Eformat = \nonfillfinish
  2480.   \gobble
  2481. % @flushleft (same as @format) and @flushright.
  2482. \def\flushleft{\begingroup
  2483.   \let\nonarrowing = t
  2484.   \nonfillstart
  2485.   \let\Eflushleft = \nonfillfinish
  2486.   \gobble
  2487. \def\flushright{\begingroup
  2488.   \let\nonarrowing = t
  2489.   \nonfillstart
  2490.   \let\Eflushright = \nonfillfinish
  2491.   \advance\leftskip by 0pt plus 1fill
  2492.   \gobble}
  2493. % @quotation does normal linebreaking (hence we can't use \nonfillstart)
  2494. % and narrows the margins.
  2495. \def\quotation{%
  2496.   \begingroup\inENV %This group ends at the end of the @quotation body
  2497.   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
  2498.   \singlespace
  2499.   \parindent=0pt
  2500.   % We have retained a nonzero parskip for the environment, since we're
  2501.   % doing normal filling. So to avoid extra space below the environment...
  2502.   \def\Equotation{\parskip = 0pt \nonfillfinish}%
  2503.   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
  2504.   \ifx\nonarrowing\relax
  2505.     \advance\leftskip by \lispnarrowing
  2506.     \advance\rightskip by \lispnarrowing
  2507.     \exdentamount = \lispnarrowing
  2508.     \let\nonarrowing = \relax
  2509.   \fi
  2510. \message{defuns,}
  2511. % Define formatter for defuns
  2512. % First, allow user to change definition object font (\df) internally
  2513. \def\setdeffont #1 {\csname DEF#1\endcsname}
  2514. \newskip\defbodyindent \defbodyindent=.4in
  2515. \newskip\defargsindent \defargsindent=50pt
  2516. \newskip\deftypemargin \deftypemargin=12pt
  2517. \newskip\deflastargmargin \deflastargmargin=18pt
  2518. \newcount\parencount
  2519. % define \functionparens, which makes ( and ) and & do special things.
  2520. % \functionparens affects the group it is contained in.
  2521. \def\activeparens{%
  2522. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  2523. \catcode`\[=\active \catcode`\]=\active}
  2524. % Make control sequences which act like normal parenthesis chars.
  2525. \let\lparen = ( \let\rparen = )
  2526. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  2527. % Be sure that we always have a definition for `(', etc.  For example,
  2528. % if the fn name has parens in it, \boldbrax will not be in effect yet,
  2529. % so TeX would otherwise complain about undefined control sequence.
  2530. \global\let(=\lparen \global\let)=\rparen
  2531. \global\let[=\lbrack \global\let]=\rbrack
  2532. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  2533. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  2534. % Definitions of (, ) and & used in args for functions.
  2535. % This is the definition of ( outside of all parentheses.
  2536. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
  2537. \global\advance\parencount by 1 }
  2538. % This is the definition of ( when already inside a level of parens.
  2539. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  2540. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  2541. % also in that case restore the outer-level definition of (.
  2542. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  2543. \global\advance \parencount by -1 }
  2544. % If we encounter &foo, then turn on ()-hacking afterwards
  2545. \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
  2546. \gdef\normalparens{\boldbrax\let&=\ampnr}
  2547. } % End of definition inside \activeparens
  2548. %% These parens (in \boldbrax) actually are a little bolder than the
  2549. %% contained text.  This is especially needed for [ and ]
  2550. \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
  2551. \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
  2552. % First, defname, which formats the header line itself.
  2553. % #1 should be the function name.
  2554. % #2 should be the type of definition, such as "Function".
  2555. \def\defname #1#2{%
  2556. % Get the values of \leftskip and \rightskip as they were
  2557. % outside the @def...
  2558. \dimen2=\leftskip
  2559. \advance\dimen2 by -\defbodyindent
  2560. \dimen3=\rightskip
  2561. \advance\dimen3 by -\defbodyindent
  2562. \noindent        %
  2563. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  2564. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  2565. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  2566. \parshape 2 0in \dimen0 \defargsindent \dimen1     %
  2567. % Now output arg 2 ("Function" or some such)
  2568. % ending at \deftypemargin from the right margin,
  2569. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  2570. {% Adjust \hsize to exclude the ambient margins,
  2571. % so that \rightline will obey them.
  2572. \advance \hsize by -\dimen2 \advance \hsize by -\dimen3
  2573. \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
  2574. % Make all lines underfull and no complaints:
  2575. \tolerance=10000 \hbadness=10000
  2576. \advance\leftskip by -\defbodyindent
  2577. \exdentamount=\defbodyindent
  2578. {\df #1}\enskip        % Generate function name
  2579. % Actually process the body of a definition
  2580. % #1 should be the terminating control sequence, such as \Edefun.
  2581. % #2 should be the "another name" control sequence, such as \defunx.
  2582. % #3 should be the control sequence that actually processes the header,
  2583. %    such as \defunheader.
  2584. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2585. \medbreak %
  2586. % Define the end token that this defining construct specifies
  2587. % so that it will exit this group.
  2588. \def#1{\endgraf\endgroup\medbreak}%
  2589. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  2590. \parindent=0in
  2591. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2592. \exdentamount=\defbodyindent
  2593. \begingroup %
  2594. \catcode 61=\active % 61 is `='
  2595. \obeylines\activeparens\spacesplit#3}
  2596. \def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
  2597. \medbreak %
  2598. % Define the end token that this defining construct specifies
  2599. % so that it will exit this group.
  2600. \def#1{\endgraf\endgroup\medbreak}%
  2601. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  2602. \parindent=0in
  2603. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2604. \exdentamount=\defbodyindent
  2605. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  2606. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  2607. \medbreak %
  2608. % Define the end token that this defining construct specifies
  2609. % so that it will exit this group.
  2610. \def#1{\endgraf\endgroup\medbreak}%
  2611. \def#2##1 ##2 {\def#4{##1}%
  2612. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  2613. \parindent=0in
  2614. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2615. \exdentamount=\defbodyindent
  2616. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  2617. % These parsing functions are similar to the preceding ones
  2618. % except that they do not make parens into active characters.
  2619. % These are used for "variables" since they have no arguments.
  2620. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  2621. \medbreak %
  2622. % Define the end token that this defining construct specifies
  2623. % so that it will exit this group.
  2624. \def#1{\endgraf\endgroup\medbreak}%
  2625. \def#2{\begingroup\obeylines\spacesplit#3}%
  2626. \parindent=0in
  2627. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2628. \exdentamount=\defbodyindent
  2629. \begingroup %
  2630. \catcode 61=\active %
  2631. \obeylines\spacesplit#3}
  2632. % This is used for \def{tp,vr}parsebody.  It could probably be used for
  2633. % some of the others, too, with some judicious conditionals.
  2634. \def\parsebodycommon#1#2#3{%
  2635.   \begingroup\inENV %
  2636.   \medbreak %
  2637.   % Define the end token that this defining construct specifies
  2638.   % so that it will exit this group.
  2639.   \def#1{\endgraf\endgroup\medbreak}%
  2640.   \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  2641.   \parindent=0in
  2642.   \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2643.   \exdentamount=\defbodyindent
  2644.   \begingroup\obeylines
  2645. \def\defvrparsebody#1#2#3#4 {%
  2646.   \parsebodycommon{#1}{#2}{#3}%
  2647.   \spacesplit{#3{#4}}%
  2648. % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
  2649. % type is just `struct', because we lose the braces in `{struct
  2650. % termios}' when \spacesplit reads its undelimited argument.  Sigh.
  2651. % \let\deftpparsebody=\defvrparsebody
  2652. % So, to get around this, we put \empty in with the type name.  That
  2653. % way, TeX won't find exactly `{...}' as an undelimited argument, and
  2654. % won't strip off the braces.
  2655. \def\deftpparsebody #1#2#3#4 {%
  2656.   \parsebodycommon{#1}{#2}{#3}%
  2657.   \spacesplit{\parsetpheaderline{#3{#4}}}\empty
  2658. % Fine, but then we have to eventually remove the \empty *and* the
  2659. % braces (if any).  That's what this does, putting the result in \tptemp.
  2660. \def\removeemptybraces\empty#1\relax{\def\tptemp{#1}}%
  2661. % After \spacesplit has done its work, this is called -- #1 is the final
  2662. % thing to call, #2 the type name (which starts with \empty), and #3
  2663. % (which might be empty) the arguments.
  2664. \def\parsetpheaderline#1#2#3{%
  2665.   \removeemptybraces#2\relax
  2666.   #1{\tptemp}{#3}%
  2667. \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
  2668. \medbreak %
  2669. % Define the end token that this defining construct specifies
  2670. % so that it will exit this group.
  2671. \def#1{\endgraf\endgroup\medbreak}%
  2672. \def#2##1 ##2 {\def#4{##1}%
  2673. \begingroup\obeylines\spacesplit{#3{##2}}}%
  2674. \parindent=0in
  2675. \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
  2676. \exdentamount=\defbodyindent
  2677. \begingroup\obeylines\spacesplit{#3{#5}}}
  2678. % Split up #2 at the first space token.
  2679. % call #1 with two arguments:
  2680. %  the first is all of #2 before the space token,
  2681. %  the second is all of #2 after that space token.
  2682. % If #2 contains no space token, all of it is passed as the first arg
  2683. % and the second is passed as empty.
  2684. {\obeylines
  2685. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  2686. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  2687. \ifx\relax #3%
  2688. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  2689. % So much for the things common to all kinds of definitions.
  2690. % Define @defun.
  2691. % First, define the processing that is wanted for arguments of \defun
  2692. % Use this to expand the args and terminate the paragraph they make up
  2693. \def\defunargs #1{\functionparens \sl
  2694. % Expand, preventing hyphenation at `-' chars.
  2695. % Note that groups don't affect changes in \hyphenchar.
  2696. \hyphenchar\tensl=0
  2697. \hyphenchar\tensl=45
  2698. \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
  2699. \interlinepenalty=10000
  2700. \advance\rightskip by 0pt plus 1fil
  2701. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2702. \def\deftypefunargs #1{%
  2703. % Expand, preventing hyphenation at `-' chars.
  2704. % Note that groups don't affect changes in \hyphenchar.
  2705. \functionparens
  2706. \tclose{#1}% avoid \code because of side effects on active chars
  2707. \interlinepenalty=10000
  2708. \advance\rightskip by 0pt plus 1fil
  2709. \endgraf\penalty 10000\vskip -\parskip\penalty 10000%
  2710. % Do complete processing of one @defun or @defunx line already parsed.
  2711. % @deffn Command forward-char nchars
  2712. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  2713. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  2714. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  2715. \catcode 61=\other % Turn off change made in \defparsebody
  2716. % @defun == @deffn Function
  2717. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  2718. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2719. \begingroup\defname {#1}{Function}%
  2720. \defunargs {#2}\endgroup %
  2721. \catcode 61=\other % Turn off change made in \defparsebody
  2722. % @deftypefun int foobar (int @var{foo}, float @var{bar})
  2723. \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
  2724. % #1 is the data type.  #2 is the name and args.
  2725. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
  2726. % #1 is the data type, #2 the name, #3 the args.
  2727. \def\deftypefunheaderx #1#2 #3\relax{%
  2728. \doind {fn}{\code{#2}}% Make entry in function index
  2729. \begingroup\defname {\code{#1} #2}{Function}%
  2730. \deftypefunargs {#3}\endgroup %
  2731. \catcode 61=\other % Turn off change made in \defparsebody
  2732. % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  2733. \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
  2734. % #1 is the classification.  #2 is the data type.  #3 is the name and args.
  2735. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
  2736. % #1 is the classification, #2 the data type, #3 the name, #4 the args.
  2737. \def\deftypefnheaderx #1#2#3 #4\relax{%
  2738. \doind {fn}{\code{#3}}% Make entry in function index
  2739. \begingroup
  2740. \normalparens % notably, turn off `&' magic, which prevents
  2741. %               at least some C++ text from working
  2742. \defname {\code{#2} #3}{#1}%
  2743. \deftypefunargs {#4}\endgroup %
  2744. \catcode 61=\other % Turn off change made in \defparsebody
  2745. % @defmac == @deffn Macro
  2746. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  2747. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2748. \begingroup\defname {#1}{Macro}%
  2749. \defunargs {#2}\endgroup %
  2750. \catcode 61=\other % Turn off change made in \defparsebody
  2751. % @defspec == @deffn Special Form
  2752. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  2753. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  2754. \begingroup\defname {#1}{Special Form}%
  2755. \defunargs {#2}\endgroup %
  2756. \catcode 61=\other % Turn off change made in \defparsebody
  2757. % This definition is run if you use @defunx
  2758. % anywhere other than immediately after a @defun or @defunx.
  2759. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  2760. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  2761. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  2762. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  2763. \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
  2764. \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
  2765. % @defmethod, and so on
  2766. % @defop {Funny Method} foo-class frobnicate argument
  2767. \def\defop #1 {\def\defoptype{#1}%
  2768. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  2769. \def\defopheader #1#2#3{%
  2770. \dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
  2771. \begingroup\defname {#2}{\defoptype{} on #1}%
  2772. \defunargs {#3}\endgroup %
  2773. % @defmethod == @defop Method
  2774. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  2775. \def\defmethodheader #1#2#3{%
  2776. \dosubind {fn}{\code{#2}}{on #1}% entry in function index
  2777. \begingroup\defname {#2}{Method on #1}%
  2778. \defunargs {#3}\endgroup %
  2779. % @defcv {Class Option} foo-class foo-flag
  2780. \def\defcv #1 {\def\defcvtype{#1}%
  2781. \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  2782. \def\defcvarheader #1#2#3{%
  2783. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2784. \begingroup\defname {#2}{\defcvtype{} of #1}%
  2785. \defvarargs {#3}\endgroup %
  2786. % @defivar == @defcv {Instance Variable}
  2787. \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
  2788. \def\defivarheader #1#2#3{%
  2789. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  2790. \begingroup\defname {#2}{Instance Variable of #1}%
  2791. \defvarargs {#3}\endgroup %
  2792. % These definitions are run if you use @defmethodx, etc.,
  2793. % anywhere other than immediately after a @defmethod, etc.
  2794. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  2795. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  2796. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  2797. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  2798. % Now @defvar
  2799. % First, define the processing that is wanted for arguments of @defvar.
  2800. % This is actually simple: just print them in roman.
  2801. % This must expand the args and terminate the paragraph they make up
  2802. \def\defvarargs #1{\normalparens #1%
  2803. \interlinepenalty=10000
  2804. \endgraf\penalty 10000\vskip -\parskip\penalty 10000}
  2805. % @defvr Counter foo-count
  2806. \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
  2807. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  2808. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  2809. % @defvar == @defvr Variable
  2810. \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
  2811. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2812. \begingroup\defname {#1}{Variable}%
  2813. \defvarargs {#2}\endgroup %
  2814. % @defopt == @defvr {User Option}
  2815. \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
  2816. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  2817. \begingroup\defname {#1}{User Option}%
  2818. \defvarargs {#2}\endgroup %
  2819. % @deftypevar int foobar
  2820. \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
  2821. % #1 is the data type.  #2 is the name.
  2822. \def\deftypevarheader #1#2{%
  2823. \doind {vr}{\code{#2}}% Make entry in variables index
  2824. \begingroup\defname {\code{#1} #2}{Variable}%
  2825. \interlinepenalty=10000
  2826. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2827. \endgroup}
  2828. % @deftypevr {Global Flag} int enable
  2829. \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
  2830. \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
  2831. \begingroup\defname {\code{#2} #3}{#1}
  2832. \interlinepenalty=10000
  2833. \endgraf\penalty 10000\vskip -\parskip\penalty 10000
  2834. \endgroup}
  2835. % This definition is run if you use @defvarx
  2836. % anywhere other than immediately after a @defvar or @defvarx.
  2837. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  2838. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  2839. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  2840. \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
  2841. \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
  2842. % Now define @deftp
  2843. % Args are printed in bold, a slight difference from @defvar.
  2844. \def\deftpargs #1{\bf \defvarargs{#1}}
  2845. % @deftp Class window height width ...
  2846. \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
  2847. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  2848. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  2849. % This definition is run if you use @deftpx, etc
  2850. % anywhere other than immediately after a @deftp, etc.
  2851. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  2852. \message{cross reference,}
  2853. % Define cross-reference macros
  2854. \newwrite \auxfile
  2855. \newif\ifhavexrefs  % True if xref values are known.
  2856. \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
  2857. % \setref{foo} defines a cross-reference point named foo.
  2858. \def\setref#1{%
  2859. \dosetq{#1-title}{Ytitle}%
  2860. \dosetq{#1-pg}{Ypagenumber}%
  2861. \dosetq{#1-snt}{Ysectionnumberandtype}}
  2862. \def\unnumbsetref#1{%
  2863. \dosetq{#1-title}{Ytitle}%
  2864. \dosetq{#1-pg}{Ypagenumber}%
  2865. \dosetq{#1-snt}{Ynothing}}
  2866. \def\appendixsetref#1{%
  2867. \dosetq{#1-title}{Ytitle}%
  2868. \dosetq{#1-pg}{Ypagenumber}%
  2869. \dosetq{#1-snt}{Yappendixletterandtype}}
  2870. % \xref, \pxref, and \ref generate cross-references to specified points.
  2871. % For \xrefX, #1 is the node name, #2 the name of the Info
  2872. % cross-reference, #3 the printed node name, #4 the name of the Info
  2873. % file, #5 the name of the printed manual.  All but the node name can be
  2874. % omitted.
  2875. \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
  2876. \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
  2877. \def\ref#1{\xrefX[#1,,,,,,,]}
  2878. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
  2879.   \def\printedmanual{\ignorespaces #5}%
  2880.   \def\printednodename{\ignorespaces #3}%
  2881.   \setbox1=\hbox{\printedmanual}%
  2882.   \setbox0=\hbox{\printednodename}%
  2883.   \ifdim \wd0 = 0pt
  2884.     % No printed node name was explicitly given.
  2885.     \ifx\SETxref-automatic-section-title\relax %
  2886.       % Use the actual chapter/section title appear inside
  2887.       % the square brackets.  Use the real section title if we have it.
  2888.       \ifdim \wd1>0pt%
  2889.         % It is in another manual, so we don't have it.
  2890.         \def\printednodename{\ignorespaces #1}%
  2891.       \else
  2892.         \ifhavexrefs
  2893.           % We know the real title if we have the xref values.
  2894.           \def\printednodename{\refx{#1-title}}%
  2895.         \else
  2896.           % Otherwise just copy the Info node name.
  2897.           \def\printednodename{\ignorespaces #1}%
  2898.         \fi%
  2899.       \fi
  2900.       \def\printednodename{#1-title}%
  2901.     \else
  2902.       % Use the node name inside the square brackets.
  2903.       \def\printednodename{\ignorespaces #1}%
  2904.     \fi
  2905.   \fi
  2906.   % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
  2907.   % insert empty discretionaries after hyphens, which means that it will
  2908.   % not find a line break at a hyphen in a node names.  Since some manuals
  2909.   % are best written with fairly long node names, containing hyphens, this
  2910.   % is a loss.  Therefore, we give the text of the node name again, so it
  2911.   % is as if TeX is seeing it for the first time.
  2912.   \ifdim \wd1 > 0pt
  2913.     \putwordsection{} ``\printednodename'' in \cite{\printedmanual}%
  2914.   \else
  2915.     % _ (for example) has to be the character _ for the purposes of the
  2916.     % control sequence corresponding to the node, but it has to expand
  2917.     % into the usual \leavevmode...\vrule stuff for purposes of
  2918.     % printing. So we \turnoffactive for the \refx-snt, back on for the
  2919.     % printing, back off for the \refx-pg.
  2920.     {\turnoffactive \refx{#1-snt}{}}%
  2921.     \space [\printednodename],\space
  2922.     \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
  2923.   \fi
  2924. \endgroup}
  2925. % \dosetq is the interface for calls from other macros
  2926. % Use \turnoffactive so that punctuation chars such as underscore
  2927. % work in node names.
  2928. \def\dosetq #1#2{{\let\folio=0 \turnoffactive%
  2929. \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
  2930. \next}}
  2931. % \internalsetq {foo}{page} expands into
  2932. % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  2933. % When the aux file is read, ' is the escape character
  2934. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  2935. % Things to be expanded by \internalsetq
  2936. \def\Ypagenumber{\folio}
  2937. \def\Ytitle{\thissection}
  2938. \def\Ynothing{}
  2939. \def\Ysectionnumberandtype{%
  2940. \ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
  2941. \else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
  2942. \else \ifnum \subsubsecno=0 %
  2943. \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
  2944. \else %
  2945. \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  2946. \fi \fi \fi }
  2947. \def\Yappendixletterandtype{%
  2948. \ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
  2949. \else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
  2950. \else \ifnum \subsubsecno=0 %
  2951. \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  2952. \else %
  2953. \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  2954. \fi \fi \fi }
  2955. \gdef\xreftie{'tie}
  2956. % Use TeX 3.0's \inputlineno to get the line number, for better error
  2957. % messages, but if we're using an old version of TeX, don't do anything.
  2958. \ifx\inputlineno\thisisundefined
  2959.   \let\linenumber = \empty % Non-3.0.
  2960. \else
  2961.   \def\linenumber{\the\inputlineno:\space}
  2962. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  2963. % If its value is nonempty, SUFFIX is output afterward.
  2964. \def\refx#1#2{%
  2965.   \expandafter\ifx\csname X#1\endcsname\relax
  2966.     % If not defined, say something at least.
  2967.     $\langle$un\-de\-fined$\rangle$%
  2968.     \ifhavexrefs
  2969.       \message{\linenumber Undefined cross reference `#1'.}%
  2970.     \else
  2971.       \ifwarnedxrefs\else
  2972.         \global\warnedxrefstrue
  2973.         \message{Cross reference values unknown; you must run TeX again.}%
  2974.       \fi
  2975.     \fi
  2976.   \else
  2977.     % It's defined, so just use it.
  2978.     \csname X#1\endcsname
  2979.   \fi
  2980.   #2% Output the suffix in any case.
  2981. % Read the last existing aux file, if any.  No error if none exists.
  2982. % This is the macro invoked by entries in the aux file.
  2983. \def\xrdef #1#2{
  2984. {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
  2985. \def\readauxfile{%
  2986. \begingroup
  2987. \catcode `\^^@=\other
  2988. \catcode `\
  2989. =\other
  2990. \catcode `\
  2991. =\other
  2992. \catcode `\^^C=\other
  2993. \catcode `\^^D=\other
  2994. \catcode `\^^E=\other
  2995. \catcode `\^^F=\other
  2996. \catcode `\^^G=\other
  2997. \catcode `\^^H=\other
  2998. \catcode `\
  2999. =\other
  3000. \catcode `\^^L=\other
  3001. \catcode `\
  3002. =\other
  3003. \catcode `\
  3004. =\other
  3005. \catcode `\
  3006. =\other
  3007. \catcode `\
  3008. =\other
  3009. \catcode `\
  3010. =\other
  3011. \catcode `\
  3012. =\other
  3013. \catcode `\
  3014. =\other
  3015. \catcode `\
  3016. =\other
  3017. \catcode `\
  3018. =\other
  3019. \catcode `\
  3020. =\other
  3021. \catcode `\
  3022. =\other
  3023. \catcode `\
  3024. =\other
  3025. \catcode 26=\other
  3026. \catcode `\^^[=\other
  3027. \catcode `\^^\=\other
  3028. \catcode `\^^]=\other
  3029. \catcode `\^^^=\other
  3030. \catcode `\^^_=\other
  3031. \catcode `\@=\other
  3032. \catcode `\^=\other
  3033. \catcode `\~=\other
  3034. \catcode `\[=\other
  3035. \catcode `\]=\other
  3036. \catcode`\"=\other
  3037. \catcode`\_=\other
  3038. \catcode`\|=\other
  3039. \catcode`\<=\other
  3040. \catcode`\>=\other
  3041. \catcode `\$=\other
  3042. \catcode `\#=\other
  3043. \catcode `\&=\other
  3044. % `\+ does not work, so use 43.
  3045. \catcode 43=\other
  3046. % Make the characters 128-255 be printing characters
  3047.   \count 1=128
  3048.   \def\loop{%
  3049.     \catcode\count 1=\other
  3050.     \advance\count 1 by 1
  3051.     \ifnum \count 1<256 \loop \fi
  3052. % the aux file uses ' as the escape.
  3053. % Turn off \ as an escape so we do not lose on
  3054. % entries which were dumped with control sequences in their names.
  3055. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  3056. % Reference to such entries still does not work the way one would wish,
  3057. % but at least they do not bomb out when the aux file is read in.
  3058. \catcode `\{=1 \catcode `\}=2
  3059. \catcode `\%=\other
  3060. \catcode `\'=0
  3061. \catcode `\\=\other
  3062. \openin 1 \jobname.aux
  3063. \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
  3064. \global\warnedobstrue
  3065. % Open the new aux file.  Tex will close it automatically at exit.
  3066. \openout \auxfile=\jobname.aux
  3067. \endgroup}
  3068. % Footnotes.
  3069. \newcount \footnoteno
  3070. % The trailing space in the following definition for supereject is
  3071. % vital for proper filling; pages come out unaligned when you do a
  3072. % pagealignmacro call if that space before the closing brace is
  3073. % removed.
  3074. \def\supereject{\par\penalty -20000\footnoteno =0 }
  3075. % @footnotestyle is meaningful for info output only..
  3076. \let\footnotestyle=\comment
  3077. \let\ptexfootnote=\footnote
  3078. {\catcode `\@=11
  3079. % Auto-number footnotes.  Otherwise like plain.
  3080. \gdef\footnote{%
  3081.   \global\advance\footnoteno by \@ne
  3082.   \edef\thisfootno{$^{\the\footnoteno}$}%
  3083.   % In case the footnote comes at the end of a sentence, preserve the
  3084.   % extra spacing after we do the footnote number.
  3085.   \let\@sf\empty
  3086.   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  3087.   % Remove inadvertent blank space before typesetting the footnote number.
  3088.   \unskip
  3089.   \thisfootno\@sf
  3090.   \footnotezzz
  3091. % Don't bother with the trickery in plain.tex to not require the
  3092. % footnote text as a parameter.  Our footnotes don't need to be so general.
  3093. \long\gdef\footnotezzz#1{\insert\footins{%
  3094.   % We want to typeset this text as a normal paragraph, even if the
  3095.   % footnote reference occurs in (for example) a display environment.
  3096.   % So reset some parameters.
  3097.   \interlinepenalty\interfootnotelinepenalty
  3098.   \splittopskip\ht\strutbox % top baseline for broken footnotes
  3099.   \splitmaxdepth\dp\strutbox
  3100.   \floatingpenalty\@MM
  3101.   \leftskip\z@skip
  3102.   \rightskip\z@skip
  3103.   \spaceskip\z@skip
  3104.   \xspaceskip\z@skip
  3105.   \parindent\defaultparindent
  3106.   % Hang the footnote text off the number.
  3107.   \hang
  3108.   \textindent{\thisfootno}%
  3109.   % Don't crash into the line above the footnote text.  Since this
  3110.   % expands into a box, it must come within the paragraph, lest it
  3111.   % provide a place where TeX can split the footnote.
  3112.   \footstrut
  3113.   #1\strut}%
  3114. }%end \catcode `\@=11
  3115. % Set the baselineskip to #1, and the lineskip and strut size
  3116. % correspondingly.  There is no deep meaning behind these magic numbers
  3117. % used as factors; they just match (closely enough) what Knuth defined.
  3118. \def\lineskipfactor{.08333}
  3119. \def\strutheightpercent{.70833}
  3120. \def\strutdepthpercent {.29167}
  3121. \def\setleading#1{%
  3122.   \normalbaselineskip = #1\relax
  3123.   \normallineskip = \lineskipfactor\normalbaselineskip
  3124.   \normalbaselines
  3125.   \setbox\strutbox =\hbox{%
  3126.     \vrule width0pt height\strutheightpercent\baselineskip
  3127.                     depth \strutdepthpercent \baselineskip
  3128. % @| inserts a changebar to the left of the current line.  It should
  3129. % surround any changed text.  This approach does *not* work if the
  3130. % change spans more than two lines of output.  To handle that, we would
  3131. % have adopt a much more difficult approach (putting marks into the main
  3132. % vertical list for the beginning and end of each change).
  3133. \def\|{%
  3134.   % \vadjust can only be used in horizontal mode.
  3135.   \leavevmode
  3136.   % Append this vertical mode material after the current line in the output.
  3137.   \vadjust{%
  3138.     % We want to insert a rule with the height and depth of the current
  3139.     % leading; that is exactly what \strutbox is supposed to record.
  3140.     \vskip-\baselineskip
  3141.     %
  3142.     % \vadjust-items are inserted at the left edge of the type.  So
  3143.     % the \llap here moves out into the left-hand margin.
  3144.     \llap{%
  3145.       %
  3146.       % For a thicker or thinner bar, change the `1pt'.
  3147.       \vrule height\baselineskip width1pt
  3148.       %
  3149.       % This is the space between the bar and the text.
  3150.       \hskip 12pt
  3151.     }%
  3152. % For a final copy, take out the rectangles
  3153. % that mark overfull boxes (in case you have decided
  3154. % that the text looks ok even though it passes the margin).
  3155. \def\finalout{\overfullrule=0pt}
  3156. % End of control word definitions.
  3157. \message{and turning on texinfo input format.}
  3158. \def\openindices{%
  3159.    \newindex{cp}%
  3160.    \newcodeindex{fn}%
  3161.    \newcodeindex{vr}%
  3162.    \newcodeindex{tp}%
  3163.    \newcodeindex{ky}%
  3164.    \newcodeindex{pg}%
  3165. % Set some numeric style parameters, for 8.5 x 11 format.
  3166. %\hsize = 6.5in
  3167. \newdimen\defaultparindent \defaultparindent = 15pt
  3168. \parindent = \defaultparindent
  3169. \parskip 18pt plus 1pt
  3170. \setleading{15pt}
  3171. \advance\topskip by 1.2cm
  3172. % Prevent underfull vbox error messages.
  3173. \vbadness=10000
  3174. % Following George Bush, just get rid of widows and orphans.
  3175. \widowpenalty=10000
  3176. \clubpenalty=10000
  3177. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  3178. % using an old version of TeX, don't do anything.  We want the amount of
  3179. % stretch added to depend on the line length, hence the dependence on
  3180. % \hsize.  This makes it come to about 9pt for the 8.5x11 format.
  3181. \ifx\emergencystretch\thisisundefined
  3182.   % Allow us to assign to \emergencystretch anyway.
  3183.   \def\emergencystretch{\dimen0}%
  3184. \else
  3185.   \emergencystretch = \hsize
  3186.   \divide\emergencystretch by 45
  3187. % Use @smallbook to reset parameters for 7x9.5 format  (or else 7x9.25)
  3188. \def\smallbook{
  3189. % These values for secheadingskip and subsecheadingskip are
  3190. % experiments.  RJC 7 Aug 1992
  3191. \global\secheadingskip = 17pt plus 6pt minus 3pt
  3192. \global\subsecheadingskip = 14pt plus 6pt minus 3pt
  3193. \global\lispnarrowing = 0.3in
  3194. \setleading{12pt}
  3195. \advance\topskip by -1cm
  3196. \global\parskip 3pt plus 1pt
  3197. \global\hsize = 5in
  3198. \global\vsize=7.5in
  3199. \global\tolerance=700
  3200. \global\hfuzz=1pt
  3201. \global\contentsrightmargin=0pt
  3202. \global\deftypemargin=0pt
  3203. \global\defbodyindent=.5cm
  3204. \global\pagewidth=\hsize
  3205. \global\pageheight=\vsize
  3206. \global\let\smalllisp=\smalllispx
  3207. \global\let\smallexample=\smalllispx
  3208. \global\def\Esmallexample{\Esmalllisp}
  3209. % Use @afourpaper to print on European A4 paper.
  3210. \def\afourpaper{
  3211. \global\tolerance=700
  3212. \global\hfuzz=1pt
  3213. \setleading{12pt}
  3214. \global\parskip 15pt plus 1pt
  3215. \global\vsize= 53\baselineskip
  3216. \advance\vsize by \topskip
  3217. %\global\hsize=   5.85in     % A4 wide 10pt
  3218. \global\hsize=  6.5in
  3219. \global\outerhsize=\hsize
  3220. \global\advance\outerhsize by 0.5in
  3221. \global\outervsize=\vsize
  3222. \global\advance\outervsize by 0.6in
  3223. \global\pagewidth=\hsize
  3224. \global\pageheight=\vsize
  3225. % Define macros to output various characters with catcode for normal text.
  3226. \catcode`\"=\other
  3227. \catcode`\~=\other
  3228. \catcode`\^=\other
  3229. \catcode`\_=\other
  3230. \catcode`\|=\other
  3231. \catcode`\<=\other
  3232. \catcode`\>=\other
  3233. \catcode`\+=\other
  3234. \def\normaldoublequote{"}
  3235. \def\normaltilde{~}
  3236. \def\normalcaret{^}
  3237. \def\normalunderscore{_}
  3238. \def\normalverticalbar{|}
  3239. \def\normalless{<}
  3240. \def\normalgreater{>}
  3241. \def\normalplus{+}
  3242. % This macro is used to make a character print one way in ttfont
  3243. % where it can probably just be output, and another way in other fonts,
  3244. % where something hairier probably needs to be done.
  3245. % #1 is what to print if we are indeed using \tt; #2 is what to print
  3246. % otherwise.  Since all the Computer Modern typewriter fonts have zero
  3247. % interword stretch (and shrink), and it is reasonable to expect all
  3248. % typewriter fonts to have this, we can check that font parameter.
  3249. \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
  3250. % Turn off all special characters except @
  3251. % (and those which the user can use as if they were ordinary).
  3252. % Most of these we simply print from the \tt font, but for some, we can
  3253. % use math or other variants that look better in normal text.
  3254. \catcode`\"=\active
  3255. \def\activedoublequote{{\tt \char '042}}
  3256. \let"=\activedoublequote
  3257. \catcode`\~=\active
  3258. \def~{{\tt \char '176}}
  3259. \chardef\hat=`\^
  3260. \catcode`\^=\active
  3261. \def^{{\tt \hat}}
  3262. \catcode`\_=\active
  3263. \def_{\ifusingtt\normalunderscore\_}
  3264. % Subroutine for the previous macro.
  3265. \def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}}
  3266. % \lvvmode is equivalent in function to \leavevmode.
  3267. % Using \leavevmode runs into trouble when written out to
  3268. % an index file due to the expansion of \leavevmode into ``\unhbox
  3269. % \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our
  3270. % magic tricks with @.
  3271. \def\lvvmode{\vbox to 0pt{}}
  3272. \catcode`\|=\active
  3273. \def|{{\tt \char '174}}
  3274. \chardef \less=`\<
  3275. \catcode`\<=\active
  3276. \def<{{\tt \less}}
  3277. \chardef \gtr=`\>
  3278. \catcode`\>=\active
  3279. \def>{{\tt \gtr}}
  3280. \catcode`\+=\active
  3281. \def+{{\tt \char 43}}
  3282. %\catcode 27=\active
  3283. %\def^^[{$\diamondsuit$}
  3284. % Set up an active definition for =, but don't enable it most of the time.
  3285. {\catcode`\==\active
  3286. \global\def={{\tt \char 61}}}
  3287. \catcode`\@=0
  3288. % \rawbackslashxx output one backslash character in current font
  3289. \global\chardef\rawbackslashxx=`\\
  3290. %{\catcode`\\=\other
  3291. %@gdef@rawbackslashxx{\}}
  3292. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  3293. {\catcode`\\=\active
  3294. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  3295. % \normalbackslash outputs one backslash in fixed width font.
  3296. \def\normalbackslash{{\tt\rawbackslashxx}}
  3297. % Say @foo, not \foo, in error messages.
  3298. \escapechar=`\@
  3299. % \catcode 17=0   % Define control-q
  3300. \catcode`\\=\active
  3301. % Used sometimes to turn off (effectively) the active characters
  3302. % even after parsing them.
  3303. @def@turnoffactive{@let"=@normaldoublequote
  3304. @let\=@realbackslash
  3305. @let~=@normaltilde
  3306. @let^=@normalcaret
  3307. @let_=@normalunderscore
  3308. @let|=@normalverticalbar
  3309. @let<=@normalless
  3310. @let>=@normalgreater
  3311. @let+=@normalplus}
  3312. @def@normalturnoffactive{@let"=@normaldoublequote
  3313. @let\=@normalbackslash
  3314. @let~=@normaltilde
  3315. @let^=@normalcaret
  3316. @let_=@normalunderscore
  3317. @let|=@normalverticalbar
  3318. @let<=@normalless
  3319. @let>=@normalgreater
  3320. @let+=@normalplus}
  3321. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  3322. % That is what \eatinput is for; after that, the `\' should revert to printing
  3323. % a backslash.
  3324. @gdef@eatinput input texinfo{@fixbackslash}
  3325. @global@let\ = @eatinput
  3326. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  3327. % the first `\{ in the file would cause an error. This macro tries to fix
  3328. % that, assuming it is called before the first `\' could plausibly occur.
  3329. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
  3330. %% These look ok in all fonts, so just make them not special.  The @rm below
  3331. %% makes sure that the current font starts out as the newly loaded cmr10
  3332. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  3333. @textfonts
  3334. @c Local variables:
  3335. @c page-delimiter: "^\\\\message"
  3336. @c End:
  3337.